OCISDK/OCISDK/ObjectStorage/IO/ObjectStorageFileInfo.cs
/// <summary>
/// Copies from ObjectStorage to the local file system.  
/// If the file already exists on the local file system and overwrite is set to false than an ArgumentException is thrown.
/// </summary>
/// <param name="destFileName">The path where to copy the file to.</param>
/// <param name="overwrite">Determines whether the file can be overwritten.</param>
/// <exception cref="T:System.IO.IOException">If the file already exists locally and overwrite is set to false.</exception>
/// <exception cref="T:System.Net.WebException"></exception>
/// <returns>FileInfo for the local file where file is copied to.</returns>
Copies from ObjectStorage to the local file system.
If the file already exists on the local file system and overwrite is set to false than an ArgumentException is thrown.
Copies from ObjectStorage to the local file system . If the file already exists on the local file system and overwrite is set to false than an ArgumentException is thrown .
public FileInfo CopyToLocal(string destFileName, bool overwrite)
        {
            if (!overwrite)
            {
                if (new FileInfo(destFileName).Exists)
                {
                    throw new IOException("File already exists");
                }
            }
            var getObjectRequest = new GetObjectRequest
            {
                NamespaceName = namespaceName,
                BucketName = bucket,
                ObjectName = ObjectStorageHelper.EncodeKey(key)
            };
            client.DownloadObject(getObjectRequest, destFileName);
            return new FileInfo(destFileName);
        }
public FileInfo CopyToLocal ( string destFileName , bool overwrite ) { if ( ! overwrite ) { if ( new FileInfo ( destFileName ) . Exists ) { throw new IOException ( " " ) ; } } var getObjectRequest = new GetObjectRequest { NamespaceName = namespaceName , BucketName = bucket , ObjectName = ObjectStorageHelper . EncodeKey ( key ) } ; client . DownloadObject ( getObjectRequest , destFileName ) ; return new FileInfo ( destFileName ) ; }
Copies from ObjectStorage to the local file system.
Copies from ObjectStorage to the local file system .
FileInfo for the local file where file is copied to.
FileInfo for the local file where file is copied to .
If the file already exists locally and overwrite is set to false.
If the file already exists locally and overwrite is set to false .
None
destFileName
string
The path where to copy the file to.
The path where to copy the file to .
overwrite
bool
Determines whether the file can be overwritten.
Determines whether the file can be overwritten .