2017-05-24 2 views
0

내 문서 업로드에 속성을 성공적으로 추가 할 수 있었지만 업로드중인 폴더와 동일한 작업을 수행 할 수 없습니다. 나는 위의 예외 얻을사용자 정의 폴더 속성 추가하기

try 
{ 
    newFolder.Properties.Add("PropertyName", "PropertyValue"); 
} 
catch(Exception ex) 
{ 
    Console.WriteLine("Unable to set folder property: " + ex.message); 
} 

그리고 메시지 :

Google.Apis.Drive.v3.Data.File newFolder = new Google.Apis.Drive.v3.Data.File 
{ 
    Name = "My Folder" 
    , MimeType = "application/vnd.google-apps.folder" 
    , Description = "Description Here" 
}; 

그리고이 다음, 나는 코드를 사용하여 속성을 추가 : 나는 기본 폴더 속성을 설정 아래 코드를 사용하고 있습니다 읽습니다 : "Object reference not set to an instance of an object."

내 첫 번째 질문은 폴더에 사용자 지정 속성을 추가 할 수 있는지 여부입니다. 그리고 만약 그렇다면, 내가 어디서 잘못 될까요?

답변

0

는 내가 처음 IDictionary<string, string> props을 작성하고 다음과 같이 속성을 추가하여이 문제를 해결 끝났다, 거기에 사람이 도움이된다면 :

Google.Apis.Drive.v3.Data.File newFolder = new Google.Apis.Drive.v3.Data.File 
{ 
    Name = "My Folder" 
    , MimeType = "application/vnd.google-apps.folder" 
    , Description = "Description Here" 
    , Properties = props 
}; 
: 폴더를 만들 때 항목에 props를 추가 마지막으로 props.Add("MyPropertyName","MyPropertyValue");

관련 문제