2016-08-09 2 views
0

으로 변환 할 수 없기 때문에 일부 콘텐츠 및 파일 이름이있는 텍스트 파일을 만든 다음 다시 편집 할 수있는 파일에 저장할 수있는 간단한 응용 프로그램을 작성하려고합니다. 후에. 그러나 몇 가지 이유로 나는 2 개의 오류가 C#과 새로운 UWP에 대해 새로운 것이되고있다. 오류에 대한 다음 도움말을 잘못 이해하고 있는지 잘 모르겠다.UWP StorageFolder에서 StorageFile

private async void writebutton(object sender, RoutedEventArgs e) 
    { 
     String fileName = txtFileName.Text; 
     String text = txtContent.Text; 
     StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; 
     (51) StorageFolder file = await localFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); 
     (52) await FileIO.WriteTextAsync(file, text); 
     MessageDialog md = new MessageDialog("File saved" + fileName); 
    } 

첫 번째 오류 (라인 51) : 암시 적으로 형식 'Windows.Storage.StorageFile을'변환 할 수 없습니다 'Windows.Storage.StorageFolder'

(라인 52)

두 번째 오류 : 인수 1 :에서 변환 할 수 없습니다 'Windows.Storage.StorageFolder'to 'Windows.Storage.IStorageFile'

+2

나는이 문제를 추측

(51) StorageFolder file = await localFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); 

변경이는 (이 이름을 변경할!) 폴더로가 아닌 파일로 정의하지만, 라인 (52)에 당신이 치료됩니다 (51) 파일 라인 관련이 그것은 파일로. –

+0

OMG 나는 그것을 알아 채지 못하는 엉덩이처럼 느껴진다. .. 고마워! – Brad

+0

당신은 환영합니다 ... 우리 모두는 그런 것들을 직시합니다 ... :) –

답변

1

이 줄이 문제입니다.

(51) StorageFile file = await localFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); 
+0

고마워요. – Brad

+1

걱정하지 마세요. 내 친구. 우리는 모두 거기에있었습니다. – AVK