示例#1
0
    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();
    }
示例#2
0
    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();
    }
示例#3
0
 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 ();
 }
示例#4
0
 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();
 }