FileMode Sabit listesi
Tanım
İşletim sisteminin bir dosyayı nasıl açması gerektiğini belirtir.Specifies how the operating system should open a file.
public enum class FileMode
public enum FileMode
[System.Serializable]
public enum FileMode
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum FileMode
type FileMode =
[<System.Serializable>]
type FileMode =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type FileMode =
Public Enum FileMode
- Devralma
- Öznitelikler
Alanlar
| Append | 6 | Varsa dosyayı açar ve dosyanın sonuna kadar arar veya yeni bir dosya oluşturur.Opens the file if it exists and seeks to the end of the file, or creates a new file. Bunun için Append izin gerekir.This requires Append permission. |
| Create | 2 | İşletim sisteminin yeni bir dosya oluşturması gerektiğini belirtir.Specifies that the operating system should create a new file. Dosya zaten varsa üzerine yazılır.If the file already exists, it will be overwritten. Bunun için Write izin gerekir.This requires Write permission. |
| CreateNew | 1 | İşletim sisteminin yeni bir dosya oluşturması gerektiğini belirtir.Specifies that the operating system should create a new file. Bunun için Write izin gerekir.This requires Write permission. Dosya zaten varsa, bir IOException özel durum oluşturulur.If the file already exists, an IOException exception is thrown. |
| Open | 3 | İşletim sisteminin var olan bir dosyayı açması gerektiğini belirtir.Specifies that the operating system should open an existing file. Dosyayı açma özelliği, numaralandırma tarafından belirtilen değere bağımlıdır FileAccess .The ability to open the file is dependent on the value specified by the FileAccess enumeration. FileNotFoundExceptionDosya yoksa bir özel durum oluşturulur.A FileNotFoundException exception is thrown if the file does not exist. |
| OpenOrCreate | 4 | Varsa, işletim sisteminin bir dosyayı açması gerektiğini belirtir; Aksi takdirde, yeni bir dosya oluşturulmalıdır.Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. Dosya ile açılırsa |
| Truncate | 5 | İşletim sisteminin var olan bir dosyayı açması gerektiğini belirtir.Specifies that the operating system should open an existing file. Dosya açıldığında, boyutu sıfır bayt olacak şekilde kesilmelidir.When the file is opened, it should be truncated so that its size is zero bytes. Bunun için Write izin gerekir.This requires Write permission. Bir |
Örnekler
Aşağıdaki FileStream Oluşturucu var olan bir dosyayı ( FileMode.Open ) açar.The following FileStream constructor opens an existing file (FileMode.Open).
FileStream^ s2 = gcnew FileStream( name, FileMode::Open, FileAccess::Read, FileShare::Read );
FileStream s2 = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read);
Dim s2 As New FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read)
Açıklamalar
Dosya oluşturma ve dosyaya metin yazma hakkında bir örnek için bkz. nasıl yapılır: bir dosyaya metin yazma.For an example of creating a file and writing text to a file, see How to: Write Text to a File. Dosyadan metin okuma hakkında bir örnek için bkz. nasıl yapılır: dosyadan metin okuma.For an example of reading text from a file, see How to: Read Text from a File. Bir ikili dosyaya okuma ve yazma örneği için bkz. nasıl yapılır: okuma ve yeni oluşturulan bir veri dosyasını yazma.For an example of reading from and writing to a binary file, see How to: Read and Write to a Newly Created Data File.
Bir FileMode parametre,, ve için FileStream IsolatedStorageFileStream Open File ve yöntemlerinde FileInfo bir dosyanın nasıl açıldığını denetlemek için ve yöntemleri içinde belirtilir.A FileMode parameter is specified in many of the constructors for FileStream, IsolatedStorageFileStream, and in the Open methods of File and FileInfo to control how a file is opened.
FileMode Parametreler, bir dosyanın üzerine yazılıp yazılmayacağını, oluşturulduğunu, açıldığını veya bir birleşiminin olduğunu denetler.FileMode parameters control whether a file is overwritten, created, opened, or some combination thereof. OpenVar olan bir dosyayı açmak için kullanın.Use Open to open an existing file. Bir dosyaya eklemek için kullanın Append .To append to a file, use Append. Dosya kesmek veya yoksa bir dosya oluşturmak için kullanın Create .To truncate a file or create a file if it doesn't exist, use Create.
Şunlara uygulanır
Ayrıca bkz.
- Open(String, FileMode)
- Open(FileMode)
- FileStream
- IsolatedStorageFileStream
- Dosya ve Akış G/ÇFile and Stream I/O
- Nasıl yapılır: Dosyadan Metin OkumaHow to: Read Text from a File
- Nasıl yapılır: Bir Dosyaya Metin YazmaHow to: Write Text to a File
- Nasıl yapılır: Yeni Oluşturulan bir Veri Dosyasını Okuma ve Dosyaya YazmaHow to: Read and Write to a Newly Created Data File