Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: DataReader Issue Pin
Guffa6-Sep-05 23:49
Guffa6-Sep-05 23:49 
QuestionTry... Catch.... help Pin
sonicsqwirl6-Sep-05 18:28
sonicsqwirl6-Sep-05 18:28 
AnswerRe: Try... Catch.... help Pin
Expert Coming6-Sep-05 18:43
Expert Coming6-Sep-05 18:43 
AnswerRe: Try... Catch.... help Pin
Christian Graus6-Sep-05 18:46
protectorChristian Graus6-Sep-05 18:46 
GeneralRe: Try... Catch.... help Pin
Expert Coming6-Sep-05 19:00
Expert Coming6-Sep-05 19:00 
AnswerRe: Try... Catch.... help Pin
S. Senthil Kumar6-Sep-05 19:12
S. Senthil Kumar6-Sep-05 19:12 
Question.net reporting addin Pin
bwagz6-Sep-05 18:08
bwagz6-Sep-05 18:08 
QuestionI can't Create File in the dir that FileSystemWatch monitor by using FileStream Pin
6-Sep-05 17:47
suss6-Sep-05 17:47 
I have some problem about FileSystemWatch

I use FileSystemWatch to monitor the dir "D:\\TEMP"
And I want to create a file in the dir "D:\\TEMP" , so path="D:\\TEMP\\test.xml"

Then It's fail when I create the File in the dir by using FileStream
And It's fail when I copy the File to the dir by using File.Move();

It's very unreasonable. =.=

My program is below ..

-------------------------------------------------------------------------
//*** Program Slice 1
public string Path = "D:\\TEMP";


//*** Program Slice 2
//*** Create FileSystemWatcher
FSWatcher1 = new System.IO.FileSystemWatcher();
FSWatcher1.Path = Path;
FSWatcher1.IncludeSubdirectories = false;
FSWatcher1.EnableRaisingEvents = true;
FSWatcher1.Created += new System.IO.FileSystemEventHandler(FSWatcher1_Created);


//*** Program Slice 3
//*** Trigger when File is Created
private void FSWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
{
//*** do something
Debug.WriteLine("〔"+e.Name+">〔"+e.FullPath+">〔"+sender.ToString()+ ">");
}


//*** Program Slice 4
//*** I found that the file is created in the dir ,
//*** but when it execute the line "m_streamWriter.Close();" , the file created is gone
FileStream fs = new FileStream(Path , FileMode.Create , FileAccess.Write);

StreamWriter m_streamWriter = new StreamWriter(fs , Big5);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.Write(Result);
m_streamWriter.Flush();
m_streamWriter.Close();


//*** Program Slice 5
//*** Then I use the method File.Move , It's still fail
File.Delete(Path);
File.Copy(Path_Temp , Path);


-- modified at 4:07 Wednesday 7th September, 2005
AnswerRe: I can't Create File in the dir that FileSystemWatch monitor by using FileStream Pin
Dave Kreskowiak8-Sep-05 1:40
mveDave Kreskowiak8-Sep-05 1:40 
QuestionChange Parent form from Dialog Box Pin
bootn6-Sep-05 17:11
bootn6-Sep-05 17:11 
AnswerRe: Change Parent form from Dialog Box Pin
Christian Graus6-Sep-05 17:29
protectorChristian Graus6-Sep-05 17:29 
QuestionMemory Management Pin
VickyC#6-Sep-05 15:08
VickyC#6-Sep-05 15:08 
AnswerRe: Memory Management Pin
Matt Gerrans6-Sep-05 15:30
Matt Gerrans6-Sep-05 15:30 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 16:02
VickyC#6-Sep-05 16:02 
GeneralRe: Memory Management Pin
Dave Kreskowiak6-Sep-05 16:18
mveDave Kreskowiak6-Sep-05 16:18 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 16:33
VickyC#6-Sep-05 16:33 
GeneralRe: Memory Management Pin
Matt Gerrans6-Sep-05 20:00
Matt Gerrans6-Sep-05 20:00 
GeneralRe: Memory Management Pin
Luis Alonso Ramos6-Sep-05 16:55
Luis Alonso Ramos6-Sep-05 16:55 
AnswerRe: Memory Management Pin
Christian Graus6-Sep-05 16:56
protectorChristian Graus6-Sep-05 16:56 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:04
VickyC#6-Sep-05 17:04 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:06
protectorChristian Graus6-Sep-05 17:06 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:14
VickyC#6-Sep-05 17:14 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:15
protectorChristian Graus6-Sep-05 17:15 
GeneralRe: Memory Management Pin
VickyC#6-Sep-05 17:32
VickyC#6-Sep-05 17:32 
GeneralRe: Memory Management Pin
Christian Graus6-Sep-05 17:35
protectorChristian Graus6-Sep-05 17:35 

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.