2

monotouchでtesseract ocrを実装しています。以下のコードをc#に変換したいです。

// 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# に変換する方法がわかりません。親切に助けてください。前もって感謝します。

4

1 に答える 1

3

ドキュメントフォルダーにアクセスするには、次を使用できます。

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

そこでファイルを管理するには、通常の System.IO メソッドを使用できます。フォルダー/ファイルの作成など。

于 2012-08-05T09:29:20.873 に答える