private void ReadFile() { // Ask for a file Gnome.Vfs.Uri uri = FileDialog.OpenFile("Read File"); // Create Stream Gnome.Vfs.VfsStream vs = new Gnome.Vfs.VfsStream(uri.ToString(), FileMode.Open); // Read File byte by byte while (true) { int c = vs.ReadByte(); if (c < 0) { Console.WriteLine("EOF"); break; } Console.Write((char)c); } // Close File vs.Close(); }
private void ShowFileInfo() { // Ask for a file Gnome.Vfs.Uri uri = FileDialog.OpenFile("Show File Info"); Console.WriteLine("Selected uri\t= {0}", uri.ToString()); // MimeType string mimeType = Gnome.Vfs.MimeType.GetMimeTypeForUri(uri.ToString()); Console.WriteLine("Mimetype\t= {0}", mimeType); // IsLocal Gnome.Vfs.FileInfoOptions options = Gnome.Vfs.FileInfoOptions.Default; Gnome.Vfs.FileInfo info = new Gnome.Vfs.FileInfo(uri.ToString(), options); Console.WriteLine("IsLocal\t\t= {0}", info.IsLocal); }
private void OpenAsync() { // Ask for a file Gnome.Vfs.Uri uri = FileDialog.OpenFile("Open File Asynchronously"); // Open the file Asynchronously Gnome.Vfs.AsyncCallback openCallback = new Gnome.Vfs.AsyncCallback(OnUriOpen); Gnome.Vfs.Async.Open(uri.ToString(), Gnome.Vfs.OpenMode.Read, 0, openCallback); }
private void WriteFile() { // Ask for a file Gnome.Vfs.Uri uri = FileDialog.SaveFile("Write to File"); // Create Stream Gnome.Vfs.VfsStream vs = new Gnome.Vfs.VfsStream(uri.ToString(), FileMode.CreateNew); // Write to the file UTF8Encoding utf8 = new UTF8Encoding(); byte [] buf = utf8.GetBytes("Testing 1 2 3, asdjfaskjdhfkajshdf"); vs.Write(buf, 0, buf.Length); // Close the file vs.Close(); }