Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: Insert more than one lakh records at a time to SQL Server Pin
Ravenet14-Apr-08 21:54
Ravenet14-Apr-08 21:54 
GeneralRe: Insert more than one lakh records at a time to SQL Server Pin
Dave Kreskowiak15-Apr-08 3:30
mveDave Kreskowiak15-Apr-08 3:30 
QuestionNeed help with drag and drop panel Pin
Pathetic Logic14-Apr-08 21:04
Pathetic Logic14-Apr-08 21:04 
GeneralRe: Need help with drag and drop panel Pin
dan!sh 14-Apr-08 21:25
professional dan!sh 14-Apr-08 21:25 
QuestionRe: Need help with drag and drop panel Pin
Pathetic Logic14-Apr-08 22:42
Pathetic Logic14-Apr-08 22:42 
Generalimage in report Pin
laleh.rajabi14-Apr-08 20:57
laleh.rajabi14-Apr-08 20:57 
GeneralRe: image in report Pin
Ravenet14-Apr-08 21:56
Ravenet14-Apr-08 21:56 
GeneralFile creation and Thread Abort Pin
Kashif Iqbal Khan14-Apr-08 20:53
Kashif Iqbal Khan14-Apr-08 20:53 
Hi!

I am using .Net 1.1. My application creates a thread to write to a file. At some conditions (e.g. User pressed Cancel button, it aborts the thread. The problem I am facing is if the code was at line

<br />
streamWriter = new StreamWriter(filename, false, Encoding.Unicode);<br />


and thread was aborted, the file cannot be written again.

Here is the log when the thread is aborted:

<br />
Thread was being aborted.<br />
   at Microsoft.Win32.Win32Native.CreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)<br />
   at Microsoft.Win32.Win32Native.UnsafeCreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)<br />
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)<br />
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)<br />
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)<br />
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)<br />
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)<br />
<br />



Here is the log of exception I get when I try to overwrite the file:

<br />
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)<br />
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)<br />
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)<br />
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)<br />
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)<br />
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)<br />
<br />



Is there any way I could assure that either the streanWriter initializes completely (because it is null due to Thread Aborted) or I could release the file?

Thanks for any help in advance
GeneralRe: File creation and Thread Abort Pin
Christian Graus14-Apr-08 21:15
protectorChristian Graus14-Apr-08 21:15 
GeneralRe: File creation and Thread Abort Pin
Kashif Iqbal Khan14-Apr-08 22:36
Kashif Iqbal Khan14-Apr-08 22:36 
GeneralRe: File creation and Thread Abort Pin
Daniel Grunwald14-Apr-08 22:47
Daniel Grunwald14-Apr-08 22:47 
QuestionHow can I look for ASCII values in my DataGrid Pin
Walaza14-Apr-08 20:26
Walaza14-Apr-08 20:26 
AnswerRe: How can I look for ASCII values in my DataGrid Pin
Christian Graus14-Apr-08 21:16
protectorChristian Graus14-Apr-08 21:16 
GeneralRe: How can I look for ASCII values in my DataGrid Pin
Vikram A Punathambekar14-Apr-08 21:36
Vikram A Punathambekar14-Apr-08 21:36 
GeneralRe: How can I look for ASCII values in my DataGrid Pin
Walaza14-Apr-08 23:29
Walaza14-Apr-08 23:29 
GeneralRe: How can I look for ASCII values in my DataGrid Pin
Christian Graus15-Apr-08 0:01
protectorChristian Graus15-Apr-08 0:01 
GeneralRe: How can I look for ASCII values in my DataGrid Pin
Walaza15-Apr-08 1:54
Walaza15-Apr-08 1:54 
GeneralRe: How can I look for ASCII values in my DataGrid Pin
Christian Graus15-Apr-08 11:01
protectorChristian Graus15-Apr-08 11:01 
AnswerRe: How can I look for ASCII values in my DataGrid Pin
Ravenet14-Apr-08 21:58
Ravenet14-Apr-08 21:58 
QuestionHow can I check for ASCII values in my DataGrid Pin
Walaza14-Apr-08 20:19
Walaza14-Apr-08 20:19 
GeneralAuto Start Up Application When Window load up Pin
HatakeKaKaShi14-Apr-08 20:04
HatakeKaKaShi14-Apr-08 20:04 
GeneralRe: Auto Start Up Application When Window load up Pin
Vikram A Punathambekar14-Apr-08 20:26
Vikram A Punathambekar14-Apr-08 20:26 
AnswerRe: Auto Start Up Application When Window load up Pin
Arjun Marwaha14-Apr-08 20:29
Arjun Marwaha14-Apr-08 20:29 
GeneralRe: Auto Start Up Application When Window load up Pin
Ravenet14-Apr-08 22:00
Ravenet14-Apr-08 22:00 
QuestionHow can I write and Read Resource file in C# application? Pin
Member 400849214-Apr-08 19:40
Member 400849214-Apr-08 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.