|
Yes that encoding is the culprit... See my answer below
|
|
|
|
|
srikanth kamuju wrote: in aP text file using c#,
Please give a sample what you want to do... perhaps i'll be able to hep you better.
Do you want to remove "_args" (minus quotes) from your lines...??
|
|
|
|
|
for example in a file
We’re actually going to increase your savings to $40 cash back!
We’re '<$40 _agscash back!
after executind my code
out put is comming as
We?re actually going to increase your savings to $40 cash back!
We?re cash back!
in the above (') is replacing with (?) automatically
actually out put i need is
We’re actually going to increase your savings to $40 cash back!
We’re 'cash back!
|
|
|
|
|
This is clear,,,
I read in 9th grade of my school that in java and c, ' needs to be escaped as \'. Since c# is a descendant of c, guessing it might be the problem. Try replacing (')s in your code with (\')s. See if it works.
EDIT:
Ignore the above... I figured out the problem
You have used ’ (backquote). It's not a part of standard windows codepage, so it is displayed as "?". Save yout text as UTF8 and write as UTF8 too. Notepad++ is a good tool to convert and edit text files.
Here's some code... how I did it
using System;
using System.Text;
using System.IO;
class Program
{
static void Main(string[] args)
{
StringBuilder newFile = new StringBuilder();
string temp = "";
string[] AllLines = File.ReadAllLines("new.txt",Encoding.UTF8);
string strStart = "<";
foreach (string strLine in AllLines)
{
Console.WriteLine(strLine);
if (strLine.Contains("CUsers") || strLine.Contains("_ags"))
{
int fIndex = strLine.IndexOf(strStart);
int sIndex = strLine.LastIndexOf("_ags");
temp = strLine.Remove(fIndex + 2, (sIndex - fIndex) + 2);
newFile.Append(temp + "\r\n");
continue;
}
newFile.Append(strLine + "\r\n");
}
Console.WriteLine(newFile.ToString());
File.WriteAllText("new2.txt", newFile.ToString(),Encoding.UTF8);
}
}
NOTE: your file needs to be encoded in UTF8 or it will result in garbled text!
TIP: Use a regex to replace... Its easy and less complicated.
modified 30-May-13 6:00am.
|
|
|
|
|
That is only necessary in strings inside the source code; not in files that are read and written.
Use the best guess
|
|
|
|
|
Oh! I didn't read the contents of the text files properly (sorry... ) now it is edited and fixed!
|
|
|
|
|
hi friends i have problem in deploying c# window application in vs2010 with sap crystal report 13.0 some error if any one have solu plz help me
crystal report can't open in client side
modified 30-May-13 4:37am.
|
|
|
|
|
You have provided no error description at all.
With this little information, no one would be able to help you.
|
|
|
|
|
Hi,
Hi have a question on classes that contains lists, and going to try hard not to make you confused.
If I have three classes:
public class Customer
{
public string CustomerCode { get; set; }
public List<warehouse> CustomerWarehouses { get; set; }
}
public class Warehouse
{
public string Name { get; set; }
public List<stock> StockCodes { get; set; }
}
public class Stock
{
public string StockCode { get; set; }
public string Description { get; set; }
public int QtyAvailable {get; set;}
}
The program starts by Populating the Customer Class.
So I will have CustomerCode "CUS123".
Then I select warehouses I want to check stock, "A1" and "B1".
So at this stage I will have the Customer Class containing customer "CUS123" and two warehouses "A1" and "B1".
Then I read stock from an excel file. Let's say I read stock code "CODEABC123".
Then for each warehouse I want to check stock and add it to the warehouse class in StockCodes list.
So warehouse "A1" and "B1" must have the stock code with their own values.
This is the code I have to populate the StockCodes list in the Warehouse Class:
public List<stock> GetStockCodeWarehouseInfo(List<stock> StockList, Customer CustomerInfo)
{
Stock tempStock = null;
foreach (Warehouse warehouse in CustomerInfo.CustomerWarehouses)
{
foreach (Stock stockcode in StockList)
{
tempStock = new Stock();
tempStock = stockcode;
//Get additional stock info
tempStock = GetAdditionalStockInfo(warehouse.Name, tempStock);
}
tempStockList.Add(tempStock);
warehouse.StockCodes.Add(tempStock);
}
return StockList;
}
When the Stock Code is added to the first Warehouse ("A1") StockCodes list the values are correct.
After the Stock Code is added to the second Warehouse ("B1") StockCodes list the first warehouse values for Stock Code is the same as values in Warehouse "B1".
So to put this in simple terms:
After Stock Code is added to first warehouse, I will have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "A1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 10
After Stock Code is added to second warehouse, I have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5
Where I should have:
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "A1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 10
Customer.Name = "CUS123"
Customer.Warehouse.Name (LIST) = "B1"
Customer.Warehouse.StockCode = "CODEABC123"
Customer.Warehouse.Description = "A STOCK CODE"
Customer.Warehouse.QtyAvailable = 5
Ay ideas on what I am doing wronng?
Thanks
|
|
|
|
|
You're not creating two lists, you're just changing the values. Also, you are not using strongly typed lists - that isn't causing your problem, but you should change to that.
public class Customer
{
public string CustomerCode { get; set; }
public List<Warehouse> CustomerWarehouses { get; set; }
}
public class Warehouse
{
public string Name { get; set; }
public List<Stock> Stocks { get; set; }
}
public class Stock
{
public string StockCode { get; set; }
public string Description { get; set; }
public int QtyAvailable {get; set;}
}
Note that I changed the name of the "StockCode" list because it is not containing StockCodes, it contains Stock objects. Given that class structure, if you wanted to create two warehouses, A1 and B1, and put one Stock item in each, you need to be careful how you create your lists - you haven't provided any method of initializing them in your classes. You didn't write constructors in these classes, so your List objects start out NULL.
Here's sample code to create two warehouses with one item each...
Create a constructor for the Customer object, to initialize your lists...
public class Customer {
public Customer() {
CustomerWarehouses = new List<Warehouse>();
}
public string CustomerCode { get; set; }
public List<Warehouse> CustomerWarehouses { get; set; }
}
Now, when you create a Customer object, you have a list ready to go, but it contains NO Warehouse objects - you'll have to add one. Can you see where I'm going with this? Think it out in steps and code up those steps - then post all your code if you're still having problems, your original question doesn't include the code we need in order to answer it. SHOW how you're populating these objects.
|
|
|
|
|
Hi, I have created a project in C#.net windows application, The Program.cs file contains two classes named as Program and Option, So my project properties contains two startup object one is windows.Program and other is windows.Options. The code has been run successfully, When i choose startup object as windows.Options then my code has starts to run from windows.Options class and if i choose windows.Program, it starts to run Program class. I need to create a installation package in my project and after installation has been done, my project has to display in start menu. <t>I can create a Installation package and installation also done. Note: The problem is the installation package runs only one startup object. i.e. before create installer, I suppose to choose startup object as "windows.Program" then after create installer and installed successfully then click my installed project, It directly run the windows.Program file. If I suppose to choose "windows.Options" before create installer. then after installation of my project and run means it starts to run windows.Options class. I need to create a single installation package and after installed this package, my project needs to shown in start menu of my system name called "project" and when i click project, it has to show both Program and options. If i choose Program, then it starts to run program part of my project, if I choose Options, then it starts to run Option part of my project. If you know guide me how to create package like this.
|
|
|
|
|
An application can only have a single entry-point. You could use a command-line argument and check that in your apps' Main method, and branch to "Program" or "Option" there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
you should use command line parameters and read them in Program.cs as below
static void Main()
{
string[] arguments = Environment.GetCommandLineArgs();
if (arguments.Length > 0)
{
foreach (string argument in arguments)
{
if (argument == "something")
{
call options;
}
else
{
call program;
}
}
}
}
next thing you have to create two application shortcuts in setup project and pass respective parameters to them. these are the same parameters which will read by program.cs.
based on this you can toggle start up object on you application.
Hope this helps..
pls reply if you need something else
|
|
|
|
|
how are charts resized in windows form the same way charts in excel. I think charts in excel convert to an image and then resized.
|
|
|
|
|
Member 9811332 wrote: I think charts in excel convert to an image and then resized. Why would you think that? Resizing is merely repainting the frame and its contents according to the new position and dimensions set by the user.
Use the best guess
|
|
|
|
|
i have some problem in handling mdi windows form
in my application i want that when open a child form after the clicking of menuitem in mdiparent form, then after that mdiparent form will be disabled and when i will close the child form the mdiparent form will be enabled again.
during the disability uer can not close the parent form , user must hav to close the child form firt thn after user may can close the parent form.
can any help me in it how to do it in c#...........
|
|
|
|
|
Arun kumar Gautam wrote: can any help me in it how to do it in c#. You just need to keep some state flags to tell you whether the form can be closed or not.
Use the best guess
|
|
|
|
|
It is very hard to understand the issue that you are facing using mdi windows form. Can you please rewrite your problem using proper language without any spelling errors?
|
|
|
|
|
The behaviour you describe is default for a modal dialog. A MDI-document is exactly that, a document-interface - not a dialog.
Use a normal form, call the ShowDialog method.
Done.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm testing the software. Database functions are connected using BackgroundWorker or not load any data into the control, only assign backgroundimage but at load user control on the user control the control it still blinks for 5 seconds. who have there a way to fix that for load control in the user control that does not flicker? Thank you everyone
|
|
|
|
|
Lương Tuấn Anh wrote: who have there a way to fix that for load control in the user control that does not flicker? Pause the painting[^] while updating the property and set your form to DoubleBuffered. You can post the code here if you want specific tips.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i will set property for form is DoubleBuffered = true . but it did not improve much. >.<
|
|
|
|
|
DoubleBuffering the form will speed up drawing "a bit". Disabling drawing as suggested will improve it "a bit" too. Without your code, I can only give these options. If you only need to assign the image to a control, then there would be not much of a "flickering", albeit the screen will show the update.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have one form and one panel. my Panel set background image are .png. form set DoubleBuffered = true. One user control have more than 10 controls (combobox, textbox...) when User control add to this panel, it flicker
< ====== My Code> http://www.mediafire.com/?1mgh5qjcly1auq2[^]
UC 1 : have DoubleBuffered = true.
But I don't want form flickered when load. I want form load the same when form don't set background image.
|
|
|
|
|
Lương Tuấn Anh wrote: But I don't want form flickered when load.
Then read the link provided to stop it drawing while running the InitializeComponents-method. How long does it take to show that form? Contains many controls?
--edit;
The idea would be for you to post the relevant code, surrounded with pre-tags, not a binary package.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|