Utilize the Full Functionality of the Whidbey File Management - Public Methods with File Class
(Page 4 of 8 )
Some of the Public Methods used with File class is as follows:
- AppendText
- Copy
- Create
- CreateText
- Delete
- Exists
- GetAttributes
- GetCreationTime
- GetCreationTimeUtc
- GetLastAccessTime
- GetLastAccessTimeUtc
- GetLastWriteTime
- Move
- Open
- OpenRead
- OpenText
- OpenWrite
- SetAttributes
- SetCreationTime
- SetCreationTimeUtc
- SetLastAccessTime
- SetLastAccessTimeUtc
- SetLastWriteTime
- SetLastWriteTimeUtc
Usage:
‘ Initializing File class aids in the creation of FileStream objects
Try
Dim strMyPath As String=”C:\Benoy\temp.txt”
Dim strMyCopyPath As String = _
“C:\Benoy\temp1.txt”
Dim objFS As FileStream = _ File.Create(strMyPath)
‘ Closing the file
objFS.Close
‘ Copy the file
File.Copy(strMyPath,strMyCopyPath
‘ Delete the file
File.Delete(strMyPath)
Catch
MessageBox.Show(“Error in File Operation”)
End Try
10. The class FileInfo provides the same file management operation as in File class such as Creating, Opening, Deleting, Copying and Moving of files using FileStream objects, except if you are not reusing the object several times because the security check is not always necessary.
11. The class FileLoadException throws exception error if any error occurs during File Load.
Some of the public methods used with this class are shown below:
- FileName – The associated filename that causes exception.
- FusionLog – Get the log file.
- HelpLink - Help Link association during exception error.
- InnerException – An inner exception that caused the current exception.
- Message - Exception Error Message.
- Source – Error Source.
- StackTrace – The associated string representation of the frames on the call stack.
- TargetSite – The associated method name that causes exception.
12. The FileNotFoundException class throws the exception error when the associated file is not found in the specified path or invalid disk access. The public methods are same as FileLoadException class.
Next: FileStream and Other Classes >>
More .NET Articles
More By Benoyraj Baskaran