Last active
December 22, 2020 10:06
-
-
Save groupdocscloud/ffdd7c22bdf290769f6aa83bb870a80d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GroupDocs.Translation Cloud CSharp Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FileExamples | |
{ | |
public class Translation_CSharp_Copy_File | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId= ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add FROM storage name here | |
string srcStorageName = ""; | |
// add TO storage name here | |
string destStorageName = ""; | |
// add FROM path here | |
string srcPath = ""; | |
// add TO path here | |
string destPath = ""; | |
FileApi api = new FileApi(conf); | |
CopyFileRequest request = new CopyFileRequest(); | |
request.srcStorageName = srcStorageName; | |
request.destStorageName = destStorageName; | |
request.srcPath = srcPath; | |
request.destPath = destPath; | |
api.CopyFile(request); | |
Console.WriteLine($"File copied"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FolderExamples | |
{ | |
public class Translation_CSharp_Copy_Folder | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add FROM storage name here | |
string srcStorageName = ""; | |
// add TO storage name here | |
string destStorageName = ""; | |
// add FROM folder name here | |
string srcPath = ""; | |
// add TO folder name here | |
string destPath = ""; | |
FolderApi api = new FolderApi(conf); | |
CopyFolderRequest request = new CopyFolderRequest(); | |
request.srcStorageName = srcStorageName; | |
request.destStorageName = destStorageName; | |
request.srcPath = srcPath; | |
request.destPath = destPath; | |
api.CopyFolder(request); | |
Console.WriteLine($"Folder copied"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FolderExamples | |
{ | |
public class Translation_CSharp_Create_Folder | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add folder name here | |
string path = ""; | |
FolderApi api = new FolderApi(conf); | |
CreateFolderRequest request = new CreateFolderRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
api.CreateFolder(request); | |
Console.WriteLine($"Folder {path} created"); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FileExamples | |
{ | |
public class Translation_CSharp_Delete_File | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add folder name here | |
string path = ""; | |
FileApi api = new FileApi(conf); | |
DeleteFileRequest request = new DeleteFileRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
api.DeleteFile(request); | |
Console.WriteLine($"File {path} deleted"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FolderExamples | |
{ | |
public class Translation_CSharp_Delete_Folder | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add folder name here | |
string path = ""; | |
FolderApi api = new FolderApi(conf); | |
DeleteFolderRequest request = new DeleteFolderRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
api.DeleteFolder(request); | |
Console.WriteLine($"Folder {path} deleted"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using System.IO; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FileExamples | |
{ | |
public class Translation_CSharp_Download_File | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add folder name here | |
string path = ""; | |
FileApi api = new FileApi(conf); | |
DownloadFileRequest request = new DownloadFileRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
Stream response = api.DownloadFile(request); | |
Console.WriteLine(response.Length); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.StorageExamples | |
{ | |
public class Translation_CSharp_File_Versions | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
StorageApi api = new StorageApi(conf); | |
GetFileVersionsRequest request = new GetFileVersionsRequest(); | |
request.storageName = storageName; | |
FileVersions response = api.GetFileVersions(request); | |
Console.WriteLine(response.Value.Count.ToString()); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FolderExamples | |
{ | |
public class Translation_CSharp_Files_List | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add folder name here | |
string path = ""; | |
FolderApi api = new FolderApi(conf); | |
GetFilesListRequest request = new GetFilesListRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
FilesList response = api.GetFilesList(request); | |
Console.WriteLine(response.Value.Count.ToString()); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FileExamples | |
{ | |
public class Translation_CSharp_Move_File | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add FROM storage name here | |
string srcStorageName = ""; | |
// add TO storage name here | |
string destStorageName = ""; | |
// add FROM path here | |
string srcPath = ""; | |
// add TO path here | |
string destPath = ""; | |
FileApi api = new FileApi(conf); | |
MoveFileRequest request = new MoveFileRequest(); | |
request.srcStorageName = srcStorageName; | |
request.destStorageName = destStorageName; | |
request.srcPath = srcPath; | |
request.destPath = destPath; | |
api.MoveFile(request); | |
Console.WriteLine($"File moved"); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FolderExamples | |
{ | |
public class Translation_CSharp_Move_Folder | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add FROM storage name here | |
string srcStorageName = ""; | |
// add TO storage name here | |
string destStorageName = ""; | |
// add FROM folder name here | |
string srcPath = ""; | |
// add TO folder name here | |
string destPath = ""; | |
FolderApi api = new FolderApi(conf); | |
MoveFolderRequest request = new MoveFolderRequest(); | |
request.srcStorageName = srcStorageName; | |
request.destStorageName = destStorageName; | |
request.srcPath = srcPath; | |
request.destPath = destPath; | |
api.MoveFolder(request); | |
Console.WriteLine($"Folder moved"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.StorageExamples | |
{ | |
public class Translation_CSharp_Object_Exists | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
StorageApi api = new StorageApi(conf); | |
ObjectExistsRequest request = new ObjectExistsRequest(); | |
request.storageName = storageName; | |
ObjectExist response = api.ObjectExists(request); | |
Console.WriteLine(response.Exists.Value.ToString()); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.StorageExamples | |
{ | |
public class Translation_CSharp_Space_Usage | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
StorageApi api = new StorageApi(conf); | |
GetDiscUsageRequest request = new GetDiscUsageRequest(); | |
request.storageName = storageName; | |
DiscUsage response = api.GetDiscUsage(request); | |
Console.WriteLine(response.UsedSize.ToString()); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.StorageExamples | |
{ | |
public class Translation_CSharp_Storage_Exists | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
StorageApi api = new StorageApi(conf); | |
StorageExistsRequest request = new StorageExistsRequest(); | |
request.storageName = storageName; | |
StorageExist response = api.StorageExists(request); | |
Console.WriteLine(response.Exists.Value.ToString()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using System.Collections.Generic; | |
using Newtonsoft.Json; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.TranslationExamples | |
{ | |
public class Translation_CSharp_Translate_Document | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add file name to translate here | |
string name = ""; | |
// add path where file is kept, leave as empty string if no specific folder | |
string folder = ""; | |
// add language pair here, see https://wiki.groupdocs.cloud/translationcloud/developer-guide/supported-languages/ | |
string pair = ""; | |
// add format of file to translate, see https://wiki.groupdocs.cloud/translationcloud/developer-guide/supported-formats/ | |
string format = ""; | |
// add format of translated file, see https://wiki.groupdocs.cloud/translationcloud/developer-guide/supported-formats/ | |
string outFormat = ""; | |
// add storage name, add "First Storage" if default storage is used | |
string storage = ""; | |
// add name of translated file | |
string saveFile = ""; | |
// add path where to save translated file, leave as empty string if no specific folder(s) | |
string savePath = ""; | |
// in case of PowerPoint translation, if master slides should be translated | |
bool masters = false; | |
// in case of Excel or Powerpoint translation, put zero based indexes of worksheets or slides to translate | |
List<int> elements = new List<int>(); | |
TranslationApi api = new TranslationApi(conf); | |
TranslateDocumentRequest request = api.CreateDocumentRequest(name, folder, pair, format, outFormat, storage, saveFile, savePath, masters, elements); | |
TranslationResponse response = api.RunTranslationTask(request); | |
Console.WriteLine(response); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using Newtonsoft.Json; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.TranslationExamples | |
{ | |
public class Translation_CSharp_Translate_Text | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add language pair here, see https://wiki.groupdocs.cloud/translationcloud/developer-guide/supported-languages/ | |
string pair = ""; | |
// add text to translate here | |
string text = ""; | |
TranslationApi api = new TranslationApi(conf); | |
TranslateTextRequest request = api.CreateTextRequest(pair, text); | |
TextResponse response = api.RunTranslationTextTask(request); | |
Console.WriteLine(response); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required). | |
using System; | |
using System.IO; | |
using GroupDocs.Translation.Cloud.SDK.NET; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model; | |
using GroupDocs.Translation.Cloud.SDK.NET.Model.Requests; | |
namespace Examples.FileExamples | |
{ | |
public class Translation_CSharp_Upload_File | |
{ | |
public static void Run() | |
{ | |
Configuration conf = new Configuration(); | |
// add your ClientId here | |
conf.ClientId = ""; | |
// add your ClientSecret here | |
conf.ClientSecret = ""; | |
// add storage name here | |
string storageName = ""; | |
// add path to file to upload on storage | |
string path = ""; | |
// add path to file to upload here | |
string localPath = ""; | |
FileStream fileStream = File.Open(localPath, FileMode.Open); | |
FileApi api = new FileApi(conf); | |
UploadFileRequest request = new UploadFileRequest(); | |
request.storageName = storageName; | |
request.path = path; | |
request.File = fileStream; | |
FilesUploadResult response = api.UploadFile(request); | |
Console.WriteLine(response.Uploaded.Count.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment