2012-08-05 117 views
2

我正在使用monotouch來壓縮tesseract ocr。我想在c#中轉換下面的代碼。如何將文件從應用程序包複製到使用單點觸摸的ios中的文檔目錄

// Set up the tessdata path. This is included in the application bundle 
// but is copied to the Documents directory on the first run. 
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentPath = ([documentPaths count] > 0) ? [documentPaths objectAtIndex:0] : nil; 

NSString *dataPath = [documentPath stringByAppendingPathComponent:@"tessdata"]; 
NSFileManager *fileManager = [NSFileManager defaultManager]; 
// If the expected store doesn't exist, copy the default store. 
if (![fileManager fileExistsAtPath:dataPath]) { 
    // get the path to the app bundle (with the tessdata dir) 
    NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; 
    NSString *tessdataPath = [bundlePath stringByAppendingPathComponent:@"tessdata"]; 
    if (tessdataPath) { 
     [fileManager copyItemAtPath:tessdataPath toPath:dataPath error:NULL]; 
    } 
} 

setenv("TESSDATA_PREFIX", [[documentPath stringByAppendingString:@"/"] UTF8String], 1); 

我不知道如何將上面的代碼轉換爲C#.kindly幫助我。 在此先感謝。

回答

3

要到Documents文件夾,您可以使用:

string docPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); 

要在有管理的文件,你可以使用正常的System.IO方法。像創建文件夾/文件等。

相關問題