예제 #1
0
        public static SkyDriveDirectory GetSkyDriveDirectory(string fullPath)
        {
            if (string.IsNullOrEmpty(fullPath))
            {
                return(null);
            }

            List <SkyDriveDirectory> skydriveListing;
            SkyDriveDirectory        selectedEntry = null;

            // root listing.
            skydriveListing = SkyDriveHelper.ListSkyDriveDirectoryWithUrl("");
            var fileFound = false;
            var sp        = fullPath.Split('/');
            var searchDir = "";

            foreach (var entry in sp.Where(x => x != ""))
            {
                var foundEntry = (from e in skydriveListing where e.Name == entry select e).FirstOrDefault();
                if (foundEntry != null && foundEntry.Type == "folder")
                {
                    searchDir       = foundEntry.Id + "/";
                    skydriveListing = ListSkyDriveDirectoryWithUrl(searchDir);
                }
                else
                {
                    return(null);
                }

                selectedEntry = foundEntry;
            }

            return(selectedEntry);
        }
예제 #2
0
        // fullPath is any number of directories then filename
        // eg. dir1/dir2/dir3/myfile.txt
        public static SkyDriveFile GetSkyDriveEntryByFileNameAndDirectory(string fullPath)
        {
            if (string.IsNullOrEmpty(fullPath))
            {
                return(null);
            }

            List <SkyDriveDirectory> skydriveListing;
            SkyDriveDirectory        selectedEntry = null;
            SkyDriveFile             selectedFile  = null;

            // root listing.
            skydriveListing = SkyDriveHelper.ListSkyDriveDirectoryWithUrl("");
            var fileFound = false;
            var sp        = fullPath.Split('/');
            var searchDir = "";

            foreach (var entry in sp)
            {
                var foundEntry = (from e in skydriveListing where e.Name == entry select e).FirstOrDefault();
                if (foundEntry != null && foundEntry.Type == "folder")
                {
                    searchDir       = foundEntry.Id + "/";
                    skydriveListing = ListSkyDriveDirectoryWithUrl(searchDir);
                }

                // cant have == "file", since "photos" etc come up as different types.
                if (foundEntry != null && foundEntry.Type != "folder")
                {
                    fileFound = true;
                    var l = ListSkyDriveFileWithUrl(foundEntry.Id);
                    if (l != null)
                    {
                        selectedFile = l;
                    }
                }

                selectedEntry = foundEntry;
            }

            if (!fileFound)
            {
                selectedFile = null;
            }

            return(selectedFile);
        }