Exemplo n.º 1
0
        private void btnSignin_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                infoTextBlock.Text = "Loading folder...";

                //列出根目录下的数据
                Dictionary <string, object> folderData = (Dictionary <string, object>)e.Result;
                List <object> folders = (List <object>)folderData["data"];

                //go through each folder and see if the isolatedstoragefolder exists
                foreach (object item in folders)
                {
                    //如果找到的txtNote目录,则直接抓取其folderID
                    Dictionary <string, object> folder = (Dictionary <string, object>)item;
                    if (folder["name"].ToString() == skyDriveFolderName)
                    {
                        skyDriveFolderID = folder["id"].ToString();
                    }
                }
                //没找到txtNote,则建立,结果交由CreateFolder_Completed处理
                if (skyDriveFolderID == string.Empty)
                {
                    Dictionary <string, object> skyDriveFolderData = new Dictionary <string, object>();
                    skyDriveFolderData.Add("name", skyDriveFolderName);

                    client.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                    client.PostAsync("me/skydrive", skyDriveFolderData); //creating the IsolatedStorageFolder in Skydrive

                    infoTextBlock.Text = "Creating folder...txtNote";
                }

                //找到了txtNote目录,则获取该目录下的文件和文件夹,交由getFiles_GetCompleted处理
                else
                {
                    client = new LiveConnectClient(session);
                    client.GetCompleted -=
                        new EventHandler <LiveOperationCompletedEventArgs>(btnSignin_GetCompleted);
                    client.GetCompleted += new EventHandler <LiveOperationCompletedEventArgs>(getFiles_GetCompleted);
                    client.GetAsync(skyDriveFolderID + "/files"); //check through the files in the folder
                }
            }


            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Exemplo n.º 2
0
        private void client_GetFolderInfoCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                var folders = e.Result["data"] as List <object>;

                foreach (IDictionary <string, object> folder in folders)
                {
                    if (folder["name"].ToString() == _skyDriveFolderName)
                    {
                        _skyDriveFolderID = folder["id"].ToString();
                        break;
                    }
                }

                if (_skyDriveFolderID == string.Empty)
                {
                    var skyDriveFolderData = new Dictionary <string, object>();
                    skyDriveFolderData.Add("name", _skyDriveFolderName);
                    client.PostCompleted += client_CreateFolderCompleted;
                    client.PostAsync("me/skydrive", skyDriveFolderData);
                }
                else
                {
                    uploadFile();
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Exemplo n.º 3
0
        private void GetFolderProperties_Completed(object sender, LiveOperationCompletedEventArgs e)
        {

            if (e.Error == null)
            {
                Dictionary<string, object> folderData = (Dictionary<string, object>)e.Result;
                List<object> folders = (List<object>)folderData["data"];

                foreach (object item in folders)
                {
                    Dictionary<string, object> folder = (Dictionary<string, object>)item;
                    if (folder["name"].ToString() == skyDriveFolderName)
                        skyDriveFolderID = folder["id"].ToString();
                }

                if (skyDriveFolderID == string.Empty)
                {
                    Dictionary<string, object> skyDriveFolderData = new Dictionary<string, object>();
                    skyDriveFolderData.Add("name", skyDriveFolderName);
                    //You can add a folder description, but for some reason it does not work.
                    //folderData.Add("description", "Folder for storing files from my WP7 app isolated storage.");
                    client.PostCompleted += new EventHandler<LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                    client.PostAsync("me/skydrive", skyDriveFolderData);
                }
                else
                    UploadFile();
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
        public override async Task <IEntryModel> CreateAsync(string fullPath, bool isDirectory, CancellationToken ct)
        {
            if (isDirectory)
            {
                await _profile.checkLoginAsync();

                string            parentPath = _profile.Path.GetDirectoryName(fullPath);
                string            name       = _profile.Path.GetFileName(fullPath);
                SkyDriveItemModel parentDir  = await _profile.ParseAsync(parentPath)
                                               as SkyDriveItemModel;

                if (parentDir == null)
                {
                    throw new DirectoryNotFoundException(parentPath);
                }

                var folderData = new Dictionary <string, object>();
                folderData.Add("name", name);
                LiveConnectClient liveClient = new LiveConnectClient(_profile.Session);
                ct.ThrowIfCancellationRequested();
                LiveOperationResult result = await liveClient.PostAsync(parentDir.UniqueId, folderData, ct);

                ct.ThrowIfCancellationRequested();
                return(new SkyDriveItemModel(_profile, result.Result, parentDir.FullPath));
            }
            else
            {
                return(new SkyDriveItemModel(Profile as SkyDriveProfile, fullPath, false));
            }
        }
Exemplo n.º 5
0
        public async Task <dynamic> AddCalendarEventAsync(String calendarId, Dictionary <String, Object> newEvent)
        {
            // requires wl.events_create scopes
            if (newEvent == null)
            {
                throw new ArgumentNullException("newEvent");
            }
            var client          = new LiveConnectClient(_session);
            var path            = String.Format("{0}/events", calendarId);
            var operationResult = await client.PostAsync(path, newEvent);

            dynamic result = operationResult.Result;

            return(result);

            // Example
            //var newEvent = new Dictionary<String, Object>
            //                    {
            //                        {"name", eventName},
            //                        {"description", eventDescription},
            //                        {"start_time", startTimeDate},
            //                        {"end_time", endTimeDate},
            //                        {"location", locationText},
            //                        {"is_all_day_event", false},
            //                        {"availability", "busy"},
            //                        {"visibility", "public"}
            //                    };

            //var client = new LiveConnectClient(_session);
            //var path = String.Format("{0}/events", calendarId);
            //var operationResult = await client.PostAsync(path, newEvent);
            //dynamic result = operationResult.Result;
            //return result;
        }
Exemplo n.º 6
0
        public async Task <string> CreateDirectoryAsync(string folderName, string parentFolder)
        {
            string folderId = null;

            // Retrieves all the directories.
            var queryFolder = parentFolder + "/files?filter=folders,albums";
            var opResult    = await _liveClient.GetAsync(queryFolder, CreateTimeoutCancellationToken(GetRequestTimeoutTimeSpan));

            dynamic result = opResult.Result;

            foreach (dynamic folder in result.data)
            {
                // Checks if current folder has the passed name.
                if (folder.name.ToLowerInvariant() == folderName.ToLowerInvariant())
                {
                    folderId = folder.id;
                    break;
                }
            }

            if (folderId == null)
            {
                // Directory hasn't been found, so creates it using the PostAsync method.
                var folderData = new Dictionary <string, object>();
                folderData.Add("name", folderName);
                opResult = await _liveClient.PostAsync(parentFolder, folderData);

                result = opResult.Result;

                // Retrieves the id of the created folder.
                folderId = result.id;
            }

            return(folderId);
        }
Exemplo n.º 7
0
        private async Task <String> CreateExportFolder(LiveConnectClient client)
        {
            LiveOperationResult opResult = await client.GetAsync("me/skydrive/files");

            var            result  = opResult.Result;
            IList <object> results = result["data"] as IList <object>;

            if (results == null)
            {
                throw new LiveConnectException();
            }
            object o = results
                       .Where(d => (d as IDictionary <string, object>)["name"].Equals(EXPORT_FOLDER))
                       .FirstOrDefault();
            string id = null;

            if (o == null)
            {
                var folderData = new Dictionary <string, object>();
                folderData.Add("name", EXPORT_FOLDER);
                opResult = await client.PostAsync("me/skydrive", folderData);

                dynamic postResult = opResult.Result;
                id = postResult.id;
            }
            else
            {
                IDictionary <string, object> folderProperties = o as IDictionary <string, object>;
                id = folderProperties["id"] as string;
            }
            return(id);
        }
Exemplo n.º 8
0
        private static async Task <string> GetFolder(LiveConnectClient client, string parentFolder, string folderName)
        {
            string skyDriveFolderId          = null;
            LiveOperationResult liveOpResult = await client.GetAsync(parentFolder + "/files?filter=folders");

            dynamic appResult = liveOpResult.Result;

            List <object> folderData = appResult.data;

            foreach (dynamic folder in folderData)
            {
                string name = folder.name;
                if (name == folderName)
                {
                    skyDriveFolderId = folder.id;
                }
            }

            //Create your Folder on SkyDrive if does not exist
            if (string.IsNullOrEmpty(skyDriveFolderId))
            {
                var skyDriveFolderData = new Dictionary <string, object>();
                skyDriveFolderData.Add("name", folderName);
                LiveOperationResult operationResult = await client.PostAsync(parentFolder, skyDriveFolderData);

                dynamic result = operationResult.Result;
                skyDriveFolderId = result.id;
            }
            return(skyDriveFolderId);
        }
Exemplo n.º 9
0
        private void Signin_BaseFolder(object sender, LiveOperationCompletedEventArgs e)
        {
            client.GetCompleted -= Signin_BaseFolder;
            if (e.Result == null)
            {
                MessageBox.Show("Erreur lecture dossiers: " + e.Error.ToString());
                return;
            }
            List <object> entries;
            Dictionary <string, object> properties;

            entries = (List <object>)e.Result["data"];
            foreach (object entry in entries)
            {
                properties = (Dictionary <string, object>)entry;
                if ((((string)properties["name"]) == sky_base_folder) && (((string)properties["type"]) == "folder"))
                {
                    sky_base_folder_id   = (string)properties["id"];
                    textBlockStatus.Text = "Fichiers...";
                    client.GetCompleted += new EventHandler <LiveOperationCompletedEventArgs>(Show_Files_Completed);
                    client.GetAsync(sky_base_folder_id + "/files");
                }
            }
            if (sky_base_folder_id == null)
            {// create repertoire + recup ID
                Dictionary <string, object> folderData = new Dictionary <string, object>();
                folderData.Add("name", sky_base_folder);
                client.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(Signin_BaseFolder_Completed);
                client.PostAsync("me/skydrive", folderData);
            }
        }
Exemplo n.º 10
0
        public async Task <dynamic> AddContactAsync(IDictionary <String, Object> newContact)
        {
            // requires wl.contacts_create scope
            if (newContact == null)
            {
                throw new ArgumentNullException("newContact");
            }
            var client          = new LiveConnectClient(_session);
            var path            = String.Format("{0}/contacts", Me);
            var operationResult = await client.PostAsync(path, newContact);

            dynamic result = operationResult.Result;

            return(result);

            // Example:
            //var newContact = new Dictionary<String, Object>
            //                     {
            //                         {"first_name", "Joe"},
            //                         {"last_name", "Smith"},
            //                     };
            //var client = new LiveConnectClient(_session);
            //var operationResult = await client.PostAsync("me/contacts", newContact);
            //dynamic result = operationResult.Result;
            //return result;
        }
        internal static async Task <OneDriveInfoResult> CreateFolderInFolderAsync(this LiveConnectClient client, string desiredFolderName, string rootFolderId, CancellationToken cancellationToken)
        {
            var folderData = new Dictionary <string, object> {
                { "name", desiredFolderName }
            };
            var result = await client.PostAsync(rootFolderId, folderData, cancellationToken);

            return(new OneDriveInfoResult(true, OneDriveItem.GetItem(result)));
        }
Exemplo n.º 12
0
        static void ClientGetFolderList_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null)
                {
                    bool          dataFolderExists = false;
                    List <object> data             = (List <object>)e.Result["data"];
                    foreach (IDictionary <string, object> dictionary in data)
                    {
                        if (string.IsNullOrEmpty(skyDriveFolderID))
                        {
                            if (dictionary.ContainsKey("name") && (string)dictionary["name"] == SettingsApi.SkyDriveFolderName &&
                                dictionary.ContainsKey("type") && (string)dictionary["type"] == "folder")
                            {
                                if (dictionary.ContainsKey("id"))
                                {
                                    skyDriveFolderID = (string)dictionary["id"];
                                    dataFolderExists = true;
                                }
                            }
                        }
                    }

                    if (!dataFolderExists)
                    {
                        // create SkyDrive data folder
                        Dictionary <string, object> body = new Dictionary <string, object>();
                        body.Add("name", SettingsApi.SkyDriveFolderName);
                        object[] state = new object[2];
                        state[0] = "create folder";
                        state[1] = body["name"];

                        try
                        {
                            LiveConnectClient createFolderClient = new LiveConnectClient(App.Session);
                            createFolderClient.PostCompleted += new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
                            createFolderClient.PostAsync("/me/skydrive", body, state);
                        }
                        catch (Exception eCreateFolder)
                        {
                            MessageBox.Show("Nie można utworzyć folderu na SkyDrive: " + eCreateFolder.Message);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Problem z dostępem do SkyDrive: " + e.Error.Message);
                }
            }
            catch (Exception eFolder)
            {
                Debug.WriteLine("Błąd konfiguracji folderu: " + eFolder.Message);
            }
        }
Exemplo n.º 13
0
        private static async Task <string> CreateFolderInSkydrive(LiveConnectClient client)
        {
            var folderData = new Dictionary <string, object>();

            folderData.Add("name", "EventBuddy");
            var createFolderResult = await client.PostAsync("me/skydrive", folderData);

            dynamic creationResult = createFolderResult.Result;

            return(creationResult.id);
        }
        /// <summary>
        /// Subscribe to a public calendar.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="subscribeUrl">For example: webcal://ical.mac.com/fredduck/Anime47Game32Birthdays.ics</param>
        /// <returns></returns>
        public async Task Subscribe(string name, string description, string subscribeUrl, string[] scopes = null)
        {
            LiveConnectClient liveClient = await GetConnectClientAsync(scopes);

            var calendar = new Dictionary <string, object>();

            calendar.Add("name", name);
            calendar.Add("description", description);
            calendar.Add("subscription_url", "");
            LiveOperationResult operationResult = await liveClient.PostAsync("me/calendars", calendar);
        }
Exemplo n.º 15
0
        private async Task <string> CreateFolder(LiveConnectClient client)
        {
            var folderData = new Dictionary <string, object>();

            folderData.Add("name", _passwordsFolder);
            LiveOperationResult operationResult = await client.PostAsync(_basePath, folderData);

            dynamic result = operationResult.Result;

            return(result.id);
        }
Exemplo n.º 16
0
        private async Task <string> CreateSkydriveFolder(string folderName)
        {
            var folderData = new Dictionary <string, object>();

            folderData.Add("name", folderName);
            var operationResult = await _client.PostAsync("me/skydrive", folderData);

            dynamic result = operationResult.Result;

            return(string.Format("{0}", result.id));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create_new_album crates a new album
        /// </summary>
        private async void Create_new_album()
        {
            Dictionary <string, object> folderData = new Dictionary <string, object>();

            folderData.Add("name", NewAlbumName);
            folderData.Add("type", "album");
            LiveConnectClient   client = new LiveConnectClient(App.Session);
            LiveOperationResult result = await client.PostAsync("me/skydrive", folderData);

            CreateFolder_Completed(result);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Create_new_album crates a new album
        /// </summary>
        private void Create_new_album()
        {
            Dictionary <string, object> folderData = new Dictionary <string, object>();

            folderData.Add("name", NewAlbumName);
            folderData.Add("type", "album");
            LiveConnectClient client = new LiveConnectClient(App.Session);

            client.PostCompleted +=
                new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
            client.PostAsync("me/skydrive", folderData);
        }
        public void TestPostWhiteSpaceStringPath()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.PostAsync("\t\n ", new Dictionary <string, object>());
                Assert.Fail("Expected ArguementException to be thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
Exemplo n.º 20
0
        private static async Task <string> createSkyDriveFolder(string folderName, LiveConnectClient client)
        {
            var folderData = new Dictionary <string, object>();

            folderData.Add("name", folderName);
            LiveOperationResult operationResult =
                await client.PostAsync("me/skydrive", folderData);

            dynamic result = operationResult.Result;

            // res = string.Join(" ", "Created folder:", result.name, "ID:", result.id);
            return(result.id);
        }
Exemplo n.º 21
0
        public async Task <dynamic> CreateSkyDriveFolderAsync(String skyDriveContainingFolderId, String folderName)
        {
            // requires wl.skydrive_update scope
            var client     = new LiveConnectClient(_session);
            var folderData = new Dictionary <String, Object> {
                { "name", folderName }
            };
            var operationResult = await client.PostAsync(skyDriveContainingFolderId, folderData);

            dynamic result = operationResult.Result;

            return(result);
        }
        public void TestPostEmptyStringBody()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.PostAsync("fileId.123", string.Empty);
                Assert.Fail("Expected ArguementException to be thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
        public void TestPostNullStringBody()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                string body = null;
                connectClient.PostAsync("fileId.123", body);
                Assert.Fail("Expected ArguementNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }
        }
Exemplo n.º 24
0
        public async static Task <string> CreateFolderAsync(string parentFolderId, string folderName)
        {
            try
            {
                Dictionary <string, object> folderData = new Dictionary <string, object>();
                folderData["name"] = folderName;

                LiveOperationResult operationResult = await _client.PostAsync(parentFolderId, folderData);

                dynamic result = operationResult.Result;

                return(result.id);
            }
            catch (Exception) { }
            return(null);
        }
 /// <summary>
 /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#creating_folders
 /// To add a new folder
 /// </summary>
 public void CreateFolder()
 {
     if (session == null)
     {
         Debug.WriteLine("You must sign in first.");
     }
     else
     {
         Dictionary <string, object> folderData = new Dictionary <string, object>();
         folderData.Add("name", "A brand new folder");
         LiveConnectClient client = new LiveConnectClient(session);
         client.PostCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
         client.PostAsync("me/skydrive", folderData);
     }
 }
Exemplo n.º 26
0
        public async Task <bool> SaveToSkyDrive(SkyDriveSaveArgs args)
        {
            bool uploadSuccess = false;

            try
            {
                var loginResult = await _authClient.LoginAsync(LiveConfig.Scopes);

                if (loginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveConnectClient client = new LiveConnectClient(loginResult.Session);
                    var foldersResult        = await client.GetAsync("me/skydrive/files?filter=folders");

                    var folders = foldersResult.Result["data"] as List <object>;
                    if (folders != null)
                    {
                        var folderQuery = (from f in folders
                                           where f is IDictionary <string, object>
                                           select(IDictionary <string, object>) f);
                        _whatIEatFolderId = folderQuery.Where(it => it["name"].ToString().ToLowerInvariant().Equals("what i eat")).Select(it => it["id"].ToString()).FirstOrDefault();
                    }
                    if (string.IsNullOrWhiteSpace(_whatIEatFolderId))
                    {
                        Dictionary <string, object> folderData = new Dictionary <string, object>();
                        folderData.Add("name", "What I Eat");
                        var folderCreateResult = await client.PostAsync("me/skydrive", folderData);

                        _whatIEatFolderId = folderCreateResult.Result["id"].ToString();
                    }
                    if (!string.IsNullOrWhiteSpace(_whatIEatFolderId))
                    {
                        using (var ms = new MemoryStream(args.Encoding.GetBytes(args.Content)))
                        {
                            var uploadResult = await client.UploadAsync(_whatIEatFolderId, args.Filename, ms, OverwriteOption.Overwrite);

                            uploadSuccess = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: Log Exception
                _log.LogException(ex, "SkyDrive Upload Error");
            }
            return(uploadSuccess);
        }
Exemplo n.º 27
0
 void CreateFolder(string folderName)
 {
     Debug.WriteLine("CreateFolder");
     if (App.Current.LiveSession == null)
     {
         //infoTextBlock.Text = "You must sign in first.";
     }
     else
     {
         Dictionary <string, object> folderData = new Dictionary <string, object>();
         folderData.Add("name", folderName);
         LiveConnectClient client = new LiveConnectClient(App.Current.LiveSession);
         client.PostCompleted +=
             new EventHandler <LiveOperationCompletedEventArgs>(CreateFolder_Completed);
         client.PostAsync("me/skydrive", folderData);
     }
 }
Exemplo n.º 28
0
        async public Task <String> createFolderIfNotExists(String folderName, String rootFolder = "me/skydrive")
        {
            await loginIfNecessary();

            String createFolder = "";

            if (folderName.Contains('/'))
            {
                createFolder = folderName.Substring(0, folderName.IndexOf('/'));
                folderName   = folderName.Substring(folderName.IndexOf('/') + 1);
            }
            else
            {
                createFolder = folderName;
                folderName   = "";
            }

            String folderId = await getFolderIdForName(createFolder);

            dynamic createdFolderResult = "";

            if (String.IsNullOrEmpty(folderId))
            {
                // Folder does not exist, create it.
                var newFolder = new Dictionary <string, object>();
                newFolder.Add("name", createFolder);

                LiveOperationResult request = await liveConnect.PostAsync(rootFolder, newFolder);

                createdFolderResult = request.Result;
                folderId            = createdFolderResult.id as String;
                Debug.WriteLine("Created folder id: " + folderId);
            }

            if (folderName.Length > 0)
            {
                return(await createFolderIfNotExists(folderName, folderId));
            }
            else
            {
                return(folderId);
            }
        }
Exemplo n.º 29
0
        private async Task createFolder()
        {
            try
            {
                var folderData = new Dictionary <string, object>();
                folderData.Add("name", oneDriveFolder);
                LiveConnectClient   liveClient      = new LiveConnectClient(oneDriveAuthClient.Session);
                LiveOperationResult operationResult = await liveClient.PostAsync("me/skydrive", folderData);

                dynamic createResult = operationResult.Result;
                oneDriveFolderId = createResult.id;
                MessageBox.Show(string.Join(" ", "Created folder:", createResult.name));
                OneDriveFolderIDEnabled = true;
            }
            catch (LiveConnectException ex)
            {
                App.AppViewModel.SendExceptionReport(ex);
            }
        }
Exemplo n.º 30
0
        public static async Task <string> CreateFolderAsync(string folder, CancellationToken ct)
        {
            if (_session == null)
            {
                throw new InvalidOperationException("Session is null");
            }

            LiveConnectClient client = new LiveConnectClient(_session);

            var folderData = new Dictionary <string, object>();

            folderData.Add("name", folder);

            var operationResult = await client.PostAsync("me/skydrive", folderData, ct);

            dynamic result = operationResult.Result;

            return(result.id);
        }
 public void TestPostEmptyStringBody()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.PostAsync("fileId.123", string.Empty);
         Assert.Fail("Expected ArguementException to be thrown.");
     }
     catch (ArgumentException)
     {
     }
 }
Exemplo n.º 32
0
        private void skydrive_checkInitiated(object sender, LiveOperationCompletedEventArgs e)
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();
            Files.RootObject data = ser.Deserialize<Files.RootObject>(e.RawResult);

            bool foundFolder = false;
            foreach (Files.Datum listItem in data.data)
            {
                if (listItem.name == "UltiDrive") //Look for UltiDrive folder
                {
                    //System.Windows.MessageBox.Show("Found UltiDrive folder");
                    SkyDrive.Properties.UltiDriveFolderID = listItem.id; //Assign the UltiDrive folder ID to the SkyDrive Properties class.
                    foundFolder = true;
                }
            }

            if (foundFolder == false) //Not found, so create UltiDrive folder.
            {
                LiveConnectClient client = new LiveConnectClient(SkyDrive.Properties.session);
                var folderData = new Dictionary<string, object> { { "name", "UltiDrive" } };
                client.PostCompleted += skydrive_setUltiDriveFolderID;
                client.PostAsync("me/skydrive", folderData);
                //System.Windows.MessageBox.Show("Created UltiDrive folder!");
            }
        }
 public void TestPostNullStringBody()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         string body = null;
         connectClient.PostAsync("fileId.123", body);
         Assert.Fail("Expected ArguementNullException to be thrown.");
     }
     catch (ArgumentNullException)
     {
     }
 }
 public void TestPostWhiteSpaceStringPath()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.PostAsync("\t\n ", new Dictionary<string, object>());
         Assert.Fail("Expected ArguementException to be thrown.");
     }
     catch (ArgumentException)
     {
     }
 }