FileStream Constructor (String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity) : FileStream « File Directory « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » File Directory » FileStreamScreenshots 
FileStream Constructor (String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity)
 

Imports System
Imports System.IO
Imports System.Text
Imports System.Security.AccessControl

Module FileStreamExample
    Sub Main()
        Try
            Dim messageByte As Byte() = Encoding.ASCII.GetBytes("Here is some data.")
            Dim fs As New FileSecurity()
            fs.AddAccessRule(New FileSystemAccessRule("DOMAINNAME\AccountName", FileSystemRights.ReadData, AccessControlType.Allow))
            Dim fWrite As New FileStream("test.txt", FileMode.Create, FileSystemRights.Modify, FileShare.None, 8, FileOptions.None, fs)
            fWrite.WriteByte(System.Convert.ToByte(messageByte.Length))
            fWrite.Write(messageByte, 0, messageByte.Length)
            fWrite.Close()
            Dim fRead As New FileStream("test.txt", FileMode.Open)
            Dim length As Integer = Fix(fRead.ReadByte())
            Dim readBytes(lengthAs Byte
            fRead.Read(readBytes, 0, readBytes.Length)
            fRead.Close()
            Console.WriteLine(Encoding.ASCII.GetString(readBytes))
        Catch As Exception
            Console.WriteLine(e)
        End Try
    End Sub
End Module

   
  
Related examples in the same category
1.Use FileStream to store and read fileUse FileStream to store and read file
2.Read and Write to a Newly Created Data File
3.FileStream Class
4.Create FileStream with FileMode.Append, FileAccess.Write, FileShare.Write
5.FileStream.CanRead Property gets a value indicating whether the current stream supports reading.
6.FileStream.CanSeek Property gets a value indicating whether the current stream supports seeking.
7.FileStream.CanWrite Property gets a value indicating whether the current stream supports writing.
8.FileStream.CanRead And FileStream.CanWrite
9.FileStream.Seek Method sets the current position of this stream to the given value.
10.FileStream Class Exposes a Stream around a file
11.FileStream.CanRead Property tells whether the current stream supports reading.
12.FileStream.CanSeek Property tells whether the current stream supports seeking.
13.FileStream.CanWrite Property tells whether the current stream supports writing.
14.FileStream.Read Method Reads a block of bytes
15.FileStream.ReadByte Method Reads a byte from the file
16.FileStream.Seek Method Sets the current position of this stream to the given value.
17.Read and Write to a Newly Created Data File
w_w_w.___j__a__va___2__s.___c___o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.