2012-05-23 7 views

उत्तर

10

एक फ़ोल्डर को एक विशेष एमआईएम प्रकार के साथ फ़ाइल के रूप में माना जा सकता है: "application/vnd.google-apps.folder"।

निम्नलिखित सी # कोड होना चाहिए कि तुम क्या जरूरत है:

File body = new File(); 
body.Title = "document title"; 
body.Description = "document description"; 
body.MimeType = "application/vnd.google-apps.folder"; 

// service is an authorized Drive API service instance 
File file = service.Files.Insert(body).Fetch(); 

अधिक जानकारी के लिए डॉक्स की जाँच करें: https://developers.google.com/drive/folder

+0

मैं फ़ोल्डर बनाने में सक्षम नहीं हूं और कोई त्रुटि भी प्राप्त नहीं हुई है। इसके अलावा। फ़ेच() विधि मेरे लिए नहीं आ रही है? ड्राइव सेवा को तुरंत कैसे चालू करें? मैं इसका उपयोग इस ड्राइव सेवा डीएस = नई ड्राइव सेवा(); ds.Key = PicasaAuthToken; धन्यवाद। – Sujit

+0

प्रमाणीकरण (https://developers.google.com/drive/apps_overview) को निष्पादित करने के तरीके के बारे में जानने के लिए दस्तावेज़ों की जांच करें, एक Picasa ऑथ टोकन ड्राइव के साथ मदद नहीं करता है। –

0
//First you will need a DriveService: 

ClientSecrets cs = new ClientSecrets(); 
cs.ClientId = yourClientId; 
cs.ClientSecret = yourClientSecret; 

credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
         cs, 
         new[] { DriveService.Scope.Drive }, 
         "user", 
         CancellationToken.None, 
         null 
        ).Result; 

DriveService service = new DriveService(new BaseClientService.Initializer() 
       { 
        HttpClientInitializer = credential, 
        ApplicationName = "TheAppName" 
       }); 

//then you can upload the file: 

File body = new File(); 
body.Title = "document title"; 
body.Description = "document description"; 
body.MimeType = "application/vnd.google-apps.folder"; 

File folder = service.Files.Insert(body).Execute(); 
0

Google डिस्क API में, किसी फ़ोल्डर के अलावा कुछ नहीं माइम के साथ एक फ़ाइल है प्रकार: application/vnd.google-apps.folder

API v2 में, आप उपयोग कर सकते हैं:

// DriveService _service: Valid, authenticated Drive service 
    // string_ title: Title of the folder 
    // string _description: Description of the folder 
    // _parent: ID of the parent directory to which the folder should be created 

public static File createDirectory(DriveService _service, string _title, string _description, string _parent) 
{ 
    File NewDirectory = null; 

    File body = new File(); 
    body.Title = _title; 
    body.Description = _description; 
    body.MimeType = "application/vnd.google-apps.folder"; 
    body.Parents = new List<ParentReference>() { new ParentReference() { Id = _parent } }; 
    try 
    { 
     FilesResource.InsertRequest request = _service.Files.Insert(body); 
     NewDirectory = request.Execute(); 
    } 
    catch(Exception e) 
    { 
     MessageBox.Show(e.Message, "Error Occured"); 
    } 
    return NewDirectory; 
} 

रूट निर्देशिका में फ़ोल्डर बनाने के लिए, आप मूल आईडी के रूप में "root" पास कर सकते हैं।

संबंधित मुद्दे