2
Answers

File Stream I/O

Ask a question
jsheley

jsheley

19y
2.2k
1
I have a bit of code that makes no sense. What appears to happen is that the "OpenFileDialog" varible neutralises the File I/O. Specifially, the code below works as expected. A file named "Master_Sel.txt" is opened, and "TEST_DATA" is written into it. The file is closed. OpenFileDialog LIB_OPEN = new OpenFileDialog( );// //LIB_OPEN.ShowDialog();//<= Problem Child (%$#$@!!) LIB_OPEN.Dispose(); BinaryWriter LIB_File_Writer = new BinaryWriter(File.Open("Master_Sel.txt", FileMode.OpenOrCreate)); LIB_File_Writer.Equals(LIB_File_Writer.BaseStream); LIB_File_Writer.Write("TEST_DATA"); LIB_File_Writer.Flush(); LIB_File_Writer.Close(); When the "//LIB_OPEN.ShowDialog();" line is un-commented, the Open file dialog appears as expected, but there is no file I/O. This also happens with "Filestream" and Stream writer functions. Can some explain to me how to avoid this problem?

Answers (2)