check is file created?
-
Sunday, July 01, 2012 6:23 AM
I am using SaveDialog to create a file by passing the FileName. I want to open the file after it's created / saved already. is there anyway to check if the file was completely created? because some files will take time (few more seconds) to get created and it will throw an error when I try to open immediatelly after save because the file was not yet created..
Jassim Rahma
All Replies
-
Sunday, July 01, 2012 10:27 AM
If you are using a stream method make sure you use the FLUSH method before attempting to read the file.jdweng
- Proposed As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, July 03, 2012 12:53 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Sunday, July 08, 2012 10:19 AM
-
Monday, July 02, 2012 5:12 AM
http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspxMark Answered, if it solves your question and Vote if you found it helpful.
Rohit Arora- Proposed As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, July 03, 2012 12:53 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Sunday, July 08, 2012 10:19 AM
-
Monday, July 02, 2012 5:46 AM
Try this way,
using (SaveFileDialog dlg = new SaveFileDialog()) { .... if (dlg.ShowDialog() == DialogResult.OK) { if (File.Exists(dlg.FileName)) { Stream stream = dlg.OpenFile(); } } }
I hope this helps.Please mark this post as answer if it solved your problem. Happy Programming!
- Proposed As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, July 03, 2012 12:53 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Sunday, July 08, 2012 10:19 AM

