string folder = Path.GetDirectoryName( file );
Parse a file path with FileChooserDialog GtkSharp
Domanda
I am using a StreamReader in WeatherController.cs to read data form a CSV file. And in my MainWindow i am using a FileChooseDialog to find the file to read from. Like so:
protected void OnButton2Clicked (object sender, EventArgs e)
{
//Open file dialog and choose a file.
Gtk.FileChooserDialog fc=
new Gtk.FileChooserDialog("Choose the file to open",
this,
Gtk.FileChooserAction.Open,
"Cancel",Gtk.ResponseType.Cancel,
"Open",Gtk.ResponseType.Accept);
fc.Filter = new FileFilter ();
fc.Filter.AddPattern ("*.csv");
if (fc.Run() == (int)Gtk.ResponseType.Accept)
{
b_Next.Sensitive = true;
System.IO.FileStream file = System.IO.File.OpenRead(fc.Filename);
file.Close();
}
//Destroy() to close the File Dialog
fc.Destroy();
}
How do i get the file path from this file to be used in my WeatherController.cs StreamReader? My StreamReader:
using (StreamReader sr = new StreamReader (file))
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow