sYnced Posted February 2, 2013 at 09:09 PM Report #493988 Posted February 2, 2013 at 09:09 PM (edited) Alguém me pode dizer como manter sempre o openfile dialog aberto ? o meu código é este MessageBox.Show("Introduza o Directório do hl.exe"); DialogResult result = openFileDialog1.ShowDialog(); bool folder = false; bool pt = true; while (folder = false) { if (result == DialogResult.OK) // Test result. { string directoryPath = Path.GetDirectoryName(openFileDialog1.FileName); if (!File.Exists(directoryPath + @"\hl.exe")) { folder = false; } else { folder = true; } if (!File.Exists(directoryPath + @"\cstrike_portuguese")) { folder = false; pt = false; } else { folder = true; } if (folder = false) { MessageBox.Show("Introduza a pasta do hl.exe"); result = openFileDialog1.ShowDialog(); } else { FileStream fs = File.Create(@"win7.txt"); StreamWriter m_streamWriter = new StreamWriter(fs); // Write to the file using StreamWriter class m_streamWriter.BaseStream.Seek(0, SeekOrigin.End); if (pt == true) { m_streamWriter.Write(directoryPath + @"\cstrike_portuguese"); } else { m_streamWriter.Write(directoryPath + @"\cstrike"); } m_streamWriter.Flush(); // Read from the file using StreamReader class // StreamReader m_streamReader = new StreamReader(fs); // string str = m_streamReader.ReadLine(); } } Edited February 3, 2013 at 11:09 PM by thoga31 GeSHi
rumbafum Posted February 3, 2013 at 10:51 PM Report #494097 Posted February 3, 2013 at 10:51 PM Acho que podes usar o evento FileOk para isso. Se o ficheiro não for válido fazes set da propriedade Cancel para true e o OpenFileDialog fica aberto 1 Report
sYnced Posted February 10, 2013 at 12:41 PM Author Report #494787 Posted February 10, 2013 at 12:41 PM Obrigado vou testar, e desculpa a demora a responder!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now