This sample assumes that you have a folder named "c:\temp" on your computer. The following example opens a file with read-only access. To obtain the current working directory, see GetCurrentDirectory.įor a list of common I/O tasks, see Common I/O Tasks. Relative path information is interpreted as relative to the current working directory. The path parameter is permitted to specify relative or absolute path information. Using fs As FileStream = File.Open(path1, FileMode.Open)ĭim temp As UTF8Encoding = New UTF8Encoding(True) Using fs As FileStream = File.Open(path1, FileMode.Open, FileAccess.Write, FileShare.None)ĭim info As Byte() = New UTF8Encoding(True).GetBytes("This is some text in the file.") ' Create a temporary file, and put some data into it.ĭim path1 As String = Path.GetTempFileName() UTF8Encoding temp = new UTF8Encoding(true) Using (FileStream fs = File.Open(path, FileMode.Open)) Using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))īyte info = new UTF8Encoding(true).GetBytes("This is some text in the file.") While ( fs->Read( b, 0, b->Length ) > 0 )Ĭonsole::WriteLine( temp->GetString( b ) ) UTF8Encoding^ temp = gcnew UTF8Encoding( true ) Create a temporary file, and put some data into it.įileStream^ fs = File::Open( path, FileMode::Open, FileAccess::Write, FileShare::None ) Īrray^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ) The example then opens the file, using T:System.IO.FileMode.Open that is, if the file did not already exist, it would not be created. The following code example creates a temporary file and writes some text to it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |