|
guys, i have a problem with sorting of a file line by line due to unknown character (box [] chracter - similar to this but no space between the lines)encountered. It is included on the given data from the past years.
During sorting line by line, the compiler encounters the box/unknown character, so the compiler will break the statement/line and will result for the new statemen/line. the problem here is that instead of one line, it produces another line to be sorted for the whole file and for that my system can not be accurate anymore.
example i have a file to be sort:
//To be sort:
hello world!
Love programming!
have fun-[]--and enjoy! //[]-illustrates the unknown chracter but no spaces bet. the lines
//after sorting the data will be arranged like this:
--and enjoy! //it will be broke into two lines
have fun-
hello world!
Love programming!
Help me guys.. Dont know what to do...
regards,
JayR
|
|
|
|
|
You should read the file byte-by-byte. This will prevent your application from getting a new line everytime it encounters one of those funny block characters.
BTW I think that character is either 0x10 or 0x13, this means your file is either using a linux type of linebreak, or is using incomplete linebreaks. You can check this by splitting the data on one of these characters.
WM.
What about weapons of mass-construction?
|
|
|
|
|
how can i do that read by byte-by-byte?
it will solve my problem?
tnx...
regards,
JayR
|
|
|
|
|
i have code for sending E-mail from window application (in C#.net)by OutLook it is woking fine
i have one button on my windows form on click event i have code for sending mail when i run this application it display one another form(OlItemType) which have to ,cc every thing like simple outlook sending form i want to display that sending form on any user control or any tab page how it can possible help me
plz
For Oriensoft Technologies Pvt. Ltd.
Govind Yadav
Software Developer
E-mail: govindy@oriensoft.com
Tel: +91-22-67111555 Fax: +91-22-67111666
24 x 7 Support & Sales Toll Free : 1-800-22-5171 (India Only)
Web : http://www.oriensoft.com
|
|
|
|
|
Hi!
I developed a small C# FTP backup application (it downloads constantly from 3 FTP servers, using 3 threads). On my laptop with XP Pro it works without problems, it's running from 3 days ago. But if I try to run it on my company's server (which has Win 2003 Server) this little program crushes without any error. Simply disappears, sometimes after 15 mins, sometimes after 2 hours...
Anyone has a clue to what's happening?
|
|
|
|
|
Hi,
Did you use try...catch blocks in your application to handle exceptions?
If so, do they ignore any exception (This means, not displaying it in an errormesssage or logging it)?
I think your program is crashing in one of the threads and you catch the exception, but doesn't display it. I think this because your program doesn't display any errormessage (which every app should if it has an error and you don't catch it).
Regards WM.
What about weapons of mass-construction?
|
|
|
|
|
Thanks for the quick reply!
I'm handling exceptions with the try & catch, and i'm logging errors on a txt file, but nothing seems to explain the crushes. If more than one thread tries to write on the txt it can crash, right? Maybe this is the exception that i don't catch.
Btw, i wonder why it works well on XP and not on 2003 server...
|
|
|
|
|
Did you check the Application log in Event Viewer? My guess is that something seriously wrong happened within your app that caused the OS to terminate it immediately. Usually, it will be logged in the Application Log, so I'd suggest you take a look there.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi All:
Been reading all I can find about multi-threading in Windows Forms, but still cannot wrap my head around this topic. Thanks in advance for any assistance!
1. Need to update a progressbar control on a SDI application while the form reads a text file. The progress bar is just a simple visual indicator to inform the user that the application has not "frozen". Pretty basic stuff.
Have consulted the following resources but still don't understand,
2. Multithreaded Windows Forms Control Sample from microsoft's website
3. http://www.codeproject.com/csharp/launchprocess.asp
Be happy to answer any/all questions.
Regards,
Keith Eckstein
|
|
|
|
|
Where exactly are you facing problems? All you have to do is to do the file reading on a separate thread (created via System.Threading.Thread or through Delegate.BeginInvoke) so that you will not hold up the UI thread. Updating the progress bar is just a matter of setting the appropriate progress value as you keep reading the file, for example, you could set max value to the number of lines in the file and then keep incrementing the progress value as you read the file line by line.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil:
The deal is I have a Read function that reads the file line by line and returns the contents of the file to a text box in the form. I need to update the form's progress bar (on the UI Thread).
A. the function to increment the progress bar.
1. private void progressBarUpdate()
2. {
3. //Reset to start if required
4. if (this.progbar.Value == this.progbar.Maximum)
5. {
6. this.progbar.Value = this.progbar.Minimum ;
7. }
8. else
9. {
10. this.progbar.PerformStep();
11. }
12. }
B. the delegate
13. private delegate string ReadDelegate(string file);
C. the function that reads the file, line by line.
14. private string Read(string file)
15. {
16. StreamReader reader = new StreamReader(file);
17. string strBufferFormatted = String.Empty;
18. string strLine = String.Empty;
19. int intLines = -1;
20. while(reader.Peek() != -1)
21. {
22. strLine = reader.ReadLine();
23. intLines++;
24. //update the progress bar here
25. BeginInvoke(new MethodInvoker(progressBarUpdate));
26. strBufferFormatted = strBufferFormatted + strLine;
27. }
28. this.lblLinesUnformatted.Text = intLines.ToString() + " lines read.";
29. reader.Close();
30. return strBufferFormatted;
31. }
The form is unresponsive while the file is being read, only after the file is read do the progess bar's blue blocks increment.
What am I missing?
Regards,
Keith
|
|
|
|
|
mtbchef1 wrote: private delegate string ReadDelegate(string file);
Did you paste the whole code or just sections of it? I'm guessing from the declaration of the delegate that you are doing something like
new ReadDelegate(Read).BeginInvoke(fileName, null);
somewhere in your UI event handler? If not, you need to do something like the above. If you instead call Read directly, the UI thread remains blocked until Read completes, so any UI updates you make, including progress bar updates, will not be performed.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil:
What I have are these lines in the Click event of a button:
// Spin off a new thread to update the ProgressBar control
ReadDelegate dlg = new ReadDelegate(Read);
dlg.BeginInvoke(this.txtFile2Parse.Text, null, null);
the Text Box on the form (this.txtFile2Parse) contains the full path and file name of the file to read.
Still have no clue how this stuff is supposed to work. Apologies for being so dense...
Regards,
Keith
|
|
|
|
|
|
Hi,
I am developing an implementation that needs to disable TCP-IP on a network adapter and at the same get the MAC address of the same network adapter.
Currently I am getting the MAC address using the GetIfTable call from IPHlpApi.dll, and manually disabling TCP-IP from the adapter properties as soon as the MAC is acquired. (GetIfTable returns 0 when TCP-IP is disabled).
My aim is to keep using the GetIfTable,get the application to disable TCP-IP exactly after it gets the MAC, and renable it when the application is closed, however I have no clue how to automate this.
Any help or new ideas greatly apreciated.
Kind Regards,
Dav
|
|
|
|
|
i've created a contro with this property, i let the user can select an image for the control.
During the design time, it works.
But when i compile and try it on another pc i the image is not loaded.
So what i've to do after i load the image?
[EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]
[Category("Image state"), Description("Mouse over image")]
//[DefaultValue("")]
public string MouseMovePath
{
get
{
return MouseMove_path;
}
set
{
try
{
MouseMove_path = value;
FileStream fs = new FileStream(MouseMove_path, FileMode.Open, FileAccess.Read);
move = Image.FromStream(fs);
fs.Close();
this.Invalidate();
}
catch
{
MouseMove_path = "(none)";
}
}
}
|
|
|
|
|
I don't see how this would work properly. Your Image is being loaded from a FileStream that you're immediately closing with fs.Close() . An underlying stream has to be open for as long as the Image is in use. The next call to Invalidate() makes it try to refresh the image... but it can't, so I would expect an error thrown at that point.
--
I've killed again, haven't I?
|
|
|
|
|
Hi, I want to make the tab for my program flash in the taskbar, I have done some googling, and found the following code:
using System.Runtime.InteropServices;<br />
<br />
[DllImport("user32.DLL", EntryPoint = "FlashWindow")]<br />
public static extern int FlashWindow(int hwnd, int bInvert);
But unfortunately I have not been able to get it to do anything (calling it has no effect), in fact I don't even know what the int parameters refer to. Can anybody give me a prod in the right direction?
Thanks!
Martin
|
|
|
|
|
According to pinvoke.net the second parameter should be a bool. FlashWindow[^]
There's also a FlashWindowEx[^] function which might be more suitable for your needs.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Ah, most helpful, thank you very much!
|
|
|
|
|
Hi.
I need a complete article about software layers.
Best wishes
|
|
|
|
|
Write one
|
|
|
|
|
Hi.
I have a table in SQLServer 2005, that has two fields (Name,Family), for example.
I want in C# (VS 2005), write some lines of code to add a record to this table.
How can I do it?
(All in code)
Best wishes
|
|
|
|
|
|
Is there some code snippet that would reset local IIS when used?
Something like this one that starts browser from Windows application:
Process p = new Process();
p.StartInfo = new ProcessStartInfo("http://www.nba.com");
p.Start();
Tnx!
|
|
|
|