Note that there are some explanatory texts on larger screens.

plurals
  1. POC# folderbrowser dialog problem
    text
    copied!<p>I have a button that once clicked uses a stremReader to read a text file, and a folderbrowser dialog to save a file. Once I save the file and and click on the button again I get an error saying it cannot find the text file, and it tries to read the the text file from the path where the previous document was saved.</p> <p>Is there any way I can resolve this problem?</p> <p>Here is a part of the code:</p> <pre><code>private void Invoice_Load(object sender, EventArgs e) { try { StreamReader sr = new StreamReader(@"../../DatabasePath"); dataBase = sr.ReadLine(); if (dataBase == null) { MessageBox.Show("Please use this to choose the location of the database."); Process.Start(@"..\..\DatabaseChooser.exe"); ready = false; } if (!ready) { while (IsProcessOpen("DatabaseChooser")) { ready = false; } ready = true; if (ready) { doIfReady(); } } else if (ready) { doIfReady(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btnCreateInvoice_Click(object sender, EventArgs e) { int SelectColumnIndex = 5; foreach (DataGridViewRow row in dataGridViewInvoice.Rows) { if (row.Cells[SelectColumnIndex].Value != null &amp;&amp; Convert.ToBoolean(row.Cells[SelectColumnIndex].Value) == true) { foreach (DataGridViewCell cell in row.Cells) { if (cell.OwningColumn.Index != SelectColumnIndex) { data += (cell.Value + " "); // do some thing } } data += System.Environment.NewLine; total += (int)row.Cells["TotPrice"].Value; } } MessageBox.Show("Please choose your invoice template", "Template"); OpenFileDialog op = new OpenFileDialog(); op.ShowHelp = true; op.Filter = "Microsoft Word Documents 97-2003 (*.doc)|*.doc|Microsoft Word 2007 (*.docx)|*.docx"; if (op.ShowDialog() == DialogResult.Cancel) { this.Hide(); } MessageBox.Show("Please choose where you want to save the invoice", "Save"); FolderBrowserDialog fd = new FolderBrowserDialog(); fd.Description = "Please choose"; if (fd.ShowDialog() == DialogResult.Cancel) { this.Hide(); } string path = fd.SelectedPath + "\\" + txtFileName.Text + ".doc"; CreateWordDoc(op.FileName, path); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload