Represents the exception that is thrown when an error occurs while a file operation is in progress.
public class FileSystemException : Exception
Public Class FileSystemException
Inherits Exception
public ref class FileSystemException : public Exception
The following example demonstrates how to handle the FileSystemException exception.
using System;
using System.Collections.Generic;
using System.Text;
using ComponentPro.IO;
using ComponentPro.Net;
...
void HandlingIOException()
{
// Create a new instance of the Ftp class.
Ftp client = new Ftp();
client.Progress += client_Progress;
// Connect to the server
client.Connect("demo.componentpro.com");
// Authenticate.
client.Authenticate("test", "test");
try
{
// Upload .cs and .vb files
client.Upload(@"C:\temp\*.cs;*.vb", "/");
}
catch (FileSystemException exc)
{
if (exc.Status == FileSystemExceptionStatus.OperationCanceled)
{
Console.WriteLine("User has cancelled the file transfer.");
}
else
Console.WriteLine("Error: " + exc.Message);
}
// Close the connection.
client.Disconnect();
}
void client_Progress(object sender, FileSystemProgressEventArgs e)
{
Ftp client = (Ftp) sender;
// User can call client.Cancel() to abort file transfer.
}
Imports System.Text
Imports ComponentPro.IO
Imports ComponentPro.Net
...
Private Sub HandlingIOException()
' Create a new instance of the Ftp class.
Dim client As New Ftp()
AddHandler client.Progress, AddressOf client_Progress
' Connect to the server
client.Connect("demo.componentpro.com")
' Authenticate.
client.Authenticate("test", "test")
Try
' Upload .cs and .vb files
client.Upload("C:\temp\*.cs;*.vb", "/")
Catch exc As FileSystemException
If exc.Status = FileSystemExceptionStatus.OperationCanceled Then
Console.WriteLine("User has cancelled the file transfer.")
Else
Console.WriteLine("Error: " & exc.Message)
End If
End Try
' Close the connection.
client.Disconnect()
End Sub
Private Sub client_Progress(ByVal sender As Object, ByVal e As FileSystemProgressEventArgs)
Dim client As Ftp = CType(sender, Ftp)
' User can call client.Cancel() to abort file transfer.
End Sub
Shows how to handle FileOperationException.
using System;
using ComponentPro.IO;
using ComponentPro.Net;
...
void HandlingIOException()
{
// Create a new instance of the Sftp class.
Sftp client = new Sftp();
client.Progress += client_Progress;
// Connect to the server
client.Connect("demo.componentpro.com");
// Authenticate.
client.Authenticate("test", "test");
try
{
// Upload .cs and .vb files
client.Upload(@"C:\temp\*.cs;*.vb", "/");
}
catch (FileSystemException exc)
{
if (exc.Status == FileSystemExceptionStatus.OperationCanceled)
{
Console.WriteLine("User has cancelled the file transfer.");
}
else
Console.WriteLine("FileOperationException: " + exc.Message);
}
// Close the connection.
client.Disconnect();
}
void client_Progress(object sender, FileSystemProgressEventArgs e)
{
Sftp client = (Sftp)sender;
// User can call client.Cancel() to abort file transfer.
}
Imports ComponentPro.IO
Imports ComponentPro.Net
...
Private Sub HandlingIOException()
' Create a new instance of the Sftp class.
Dim client As New Sftp()
AddHandler client.Progress, AddressOf client_Progress
' Connect to the server
client.Connect("demo.componentpro.com")
' Authenticate.
client.Authenticate("test", "test")
Try
' Upload .cs and .vb files
client.Upload("C:\temp\*.cs;*.vb", "/")
Catch exc As FileSystemException
If exc.Status = FileSystemExceptionStatus.OperationCanceled Then
Console.WriteLine("User has cancelled the file transfer.")
Else
Console.WriteLine("FileOperationException: " & exc.Message)
End If
End Try
' Close the connection.
client.Disconnect()
End Sub
Private Sub client_Progress(ByVal sender As Object, ByVal e As FileSystemProgressEventArgs)
Dim client As Sftp = CType(sender, Sftp)
' User can call client.Cancel() to abort file transfer.
End Sub
Shows how to handle FileSystemException.
using System;
using ComponentPro.IO;
using ComponentPro.Compression;
...
void HandlingIOException()
{
// Create a new instance of the Zip class.
Zip zip = new Zip();
zip.Progress += zip_Progress;
// Open an existing file.
zip.Open("test.zip");
try
{
// Add .cs and .vb files
zip.AddFiles(@"C:\temp\*.cs;*.vb", "/");
}
catch (FileSystemException exc)
{
if (exc.Status == FileSystemExceptionStatus.OperationCanceled)
{
Console.WriteLine("User has cancelled the file transfer.");
}
else
Console.WriteLine("Error: " + exc.Message);
}
// Close the archive.
zip.Close();
}
void zip_Progress(object sender, FileSystemProgressEventArgs e)
{
Zip zip = (Zip) sender;
// User can call zip.Cancel() to abort file transfer.
}
Imports ComponentPro.IO
Imports ComponentPro.Compression
...
Private Sub HandlingIOException()
' Create a new instance of the Zip class.
Dim zip As New Zip()
AddHandler zip.Progress, AddressOf zip_Progress
' Open an existing file.
zip.Open("test.zip")
Try
' Add .cs and .vb files
zip.AddFiles("C:\temp\*.cs;*.vb", "/")
Catch exc As FileSystemException
If exc.Status = FileSystemExceptionStatus.OperationCanceled Then
Console.WriteLine("User has cancelled the file transfer.")
Else
Console.WriteLine("Error: " & exc.Message)
End If
End Try
' Close the archive.
zip.Close()
End Sub
Private Sub zip_Progress(ByVal sender As Object, ByVal e As FileSystemProgressEventArgs)
Dim zip As Zip = CType(sender, Zip)
' User can call zip.Cancel() to abort file transfer.
End Sub
ComponentPro.IO.ComponentPro.IO.FileSystemException