Click here to Skip to main content
15,896,912 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: need help!! please help me.. Pin
Christian Graus14-Jun-05 1:21
protectorChristian Graus14-Jun-05 1:21 
GeneralRe: need help!! please help me.. Pin
Bob Stanneveld14-Jun-05 3:32
Bob Stanneveld14-Jun-05 3:32 
GeneralRe: need help!! please help me.. Pin
c_ngo15-Jun-05 15:30
c_ngo15-Jun-05 15:30 
GeneralRe: need help!! please help me.. Pin
c_ngo15-Jun-05 15:35
c_ngo15-Jun-05 15:35 
QuestionHow to remove close button from window? Pin
amrutajoshi13-Jun-05 20:36
amrutajoshi13-Jun-05 20:36 
AnswerRe: How to remove close button from window? Pin
Bob Stanneveld13-Jun-05 23:58
Bob Stanneveld13-Jun-05 23:58 
AnswerRe: How to remove close button from window? Pin
Stlan14-Jun-05 0:01
Stlan14-Jun-05 0:01 
GeneralFileSystemWatcher - File used by another process Pin
g3e13-Jun-05 23:36
g3e13-Jun-05 23:36 
Hi,
I've written a windows service to parse files.It uses the FileSystemWatcher class in C# to sniff a folder for particular type of files. But when the files were being processed, i repeatedly get the error "The process cannot access the file "AAA" because it is being used by another process". To overcome this problem, i added the following. lines of code
<br />
<br />
public bool ParseEnvFile(string strFilePath)<br />
{<br />
			try<br />
			{<br />
				using(FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))<br />
				{<br />
					// Do some processing here<br />
					fs.Close();<br />
					m_nReadAttempts = 0;<br />
				}<br />
			}<br />
			catch(IOException ex)<br />
			{<br />
				if(m_nReadAttempts < 3)<br />
				{<br />
					Thread.Sleep(2000);<br />
					m_nReadAttempts++;<br />
					return ParseEnvFile(strFilePath);<br />
				}<br />
				else<br />
				{<br />
					throw ex;<br />
				}<br />
			}<br />
.....<br />
}<br />


But even this did not solve the problem. The exception still kept coming, though less frequently.
So I was forced to add a Timer event(runs every 5 mins) that would pick up all the files that were left over because of the exception.
Now, my problem is this:
When a file gets created in the folder, sometimes both the OnFileCreated event and the timer event try to access the file at the same time. Within my
service, I'm required to open the file in write mode and update some contents. I find that at times the file that gets created ends up as a 0KB file (Note: when it initially got created the file had some content in it)!!!!

Any ideas on why this happens?
Thanks for any help in resolving this problem.
Questionhow to change debug options? Pin
ThinkingPrometheus13-Jun-05 23:35
ThinkingPrometheus13-Jun-05 23:35 
GeneralExe to Dll Pin
Hemoji13-Jun-05 23:30
Hemoji13-Jun-05 23:30 
GeneralRe: Exe to Dll Pin
Rick York14-Jun-05 10:12
mveRick York14-Jun-05 10:12 
Generale trefreshes the BitMap image Pin
a_david12313-Jun-05 23:17
a_david12313-Jun-05 23:17 
GeneralRe: e trefreshes the BitMap image Pin
Christian Graus14-Jun-05 1:24
protectorChristian Graus14-Jun-05 1:24 
GeneralRe: e trefreshes the BitMap image Pin
a_david12315-Jun-05 20:27
a_david12315-Jun-05 20:27 
GeneralRe: e trefreshes the BitMap image Pin
Christian Graus16-Jun-05 12:08
protectorChristian Graus16-Jun-05 12:08 
General&quot;AfterEdit&quot; event not getting called Pin
Pazzuzu13-Jun-05 23:00
Pazzuzu13-Jun-05 23:00 
GeneralSpawning Pin
Kash13-Jun-05 22:19
Kash13-Jun-05 22:19 
GeneralRe: Spawning Pin
David Crow14-Jun-05 3:18
David Crow14-Jun-05 3:18 
GeneralDynamically Change Menu Text Pin
sweep12313-Jun-05 21:52
sweep12313-Jun-05 21:52 
GeneralRe: Dynamically Change Menu Text Pin
Weiye Chen13-Jun-05 22:44
Weiye Chen13-Jun-05 22:44 
GeneralRe: Dynamically Change Menu Text Pin
Nilesh K.13-Jun-05 23:01
Nilesh K.13-Jun-05 23:01 
GeneralRe: Dynamically Change Menu Text Pin
sweep12313-Jun-05 20:24
sweep12313-Jun-05 20:24 
Generali want ask about this code Pin
kosamoza13-Jun-05 20:47
kosamoza13-Jun-05 20:47 
GeneralRe: i want ask about this code Pin
Nilesh K.13-Jun-05 21:21
Nilesh K.13-Jun-05 21:21 
GeneralRe: i want ask about this code Pin
kosamoza13-Jun-05 22:14
kosamoza13-Jun-05 22:14 

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.