DirectoryExists() public method

public DirectoryExists ( string path ) : bool
path string
return bool
コード例 #1
0
 private static void VerifyFolderExistsAsync(IsolatedStorageFile isolatedStorageFile)
 {
     if (!isolatedStorageFile.DirectoryExists(MonthFolder))
     {
         isolatedStorageFile.CreateDirectory(MonthFolder);
     }
 }
コード例 #2
0
        public AssemblyStorageService()
        {
            Store = IsolatedStorageFile.GetUserStoreForApplication();
            Store.IncreaseQuotaTo(20971520);
            if (!Store.DirectoryExists("Modules"))
                Store.CreateDirectory("Modules");

        }
コード例 #3
0
 public IsolatedStorageResponseCache(TimeSpan expiresIn)
 {
     this.expiresIn = expiresIn;
     storage = IsolatedStorageFile.GetUserStoreForApplication();
     if (!storage.DirectoryExists("Cache"))
     {
         storage.CreateDirectory("Cache");
     }
 }
コード例 #4
0
        public static void CreateDirectoryTree(Uri feedUri, IsolatedStorageFile storage)
        {
            if (!feedUri.OriginalString.Contains('\\')) return;

            var directory = GetDirectoryPath(feedUri);

            if (!storage.DirectoryExists(directory)) 
                storage.CreateDirectory(directory);
        }
        public IsolatedStorageResponseCache(string session)
        {
            if (session == null) throw new ArgumentNullException("session");
            this._sessionKey = HashUtil.ToSHA1(session);

            //create cache dir
            _storage = IsolatedStorageFile.GetUserStoreForApplication();
            if (!_storage.DirectoryExists("ECollegeCache"))
            {
                _storage.CreateDirectory("ECollegeCache");
            }

            //create session dir
            string thisSessionDirectory = string.Format("ECollegeCache\\{0}", _sessionKey);
            if (!_storage.DirectoryExists(thisSessionDirectory))
            {
                _storage.CreateDirectory(thisSessionDirectory);
            }
        }
コード例 #6
0
        public static void CreateDirectory(string path)
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();



            if (isf.DirectoryExists(path))
            {
                isf.CreateDirectory(path);
            }
        }
        /// <summary>
        /// Creates all of the directories included in the given filepath.
        /// </summary>
        /// <param name="filepath">A string containing a filepath which may or may not contain any number of directories.</param>
        /// <param name="storage">A reference to a valid IsolatedStorageFile instance</param>
        public static void CreateDirectoryTree(string filepath, IsolatedStorageFile storage)
        {
            //If this filepath is flat and doesn't contain any folders - bail.
             if (!HasDirectories(filepath)) return;

            //Extract the full directory path from the filename
            var directory = GetFullDirectoryPath(filepath);

            //If the directory doesn't already exist, create it.
            if (!storage.DirectoryExists(directory))
                storage.CreateDirectory(directory);
        }
コード例 #8
0
ファイル: AccountManager.cs プロジェクト: fiftin/oblqo
 private void DeleteAllFilesInDirectory(IsolatedStorageFile store, string path)
 {
     if (!store.DirectoryExists(path))
     {
         return;
     }
     var files = store.GetFileNames(path + "/*");
     foreach (var file in files)
     {
         store.DeleteFile(path + "/" + file);
     }
 }
コード例 #9
0
        private void CreateDirIfNecessary(IsolatedStorageFile local, string path)
        {
            int pos = 0;
            string dir = path;

            while ((pos = dir.IndexOf('\\', pos)) != -1)
            {
                var dirname = dir.Substring(0, pos);
                if (!local.DirectoryExists(dirname))
                    local.CreateDirectory(dirname);
                pos++;
            }
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: jaslong/Recorder
        public MainPage()
        {
            InitializeComponent();

            _recorder = new Recorder(new WaveFormat());
            _storage = IsolatedStorageFile.GetUserStoreForApplication();

            if (!_storage.DirectoryExists(STORAGE_DIRECTORY))
            {
                _storage.CreateDirectory(STORAGE_DIRECTORY);
            }

            UpdateRecordings();
        }
コード例 #11
0
ファイル: CardProvider.cs プロジェクト: asizikov/PinHolder
 private static bool CheckDir(IsolatedStorageFile storage)
 {
     if (!storage.DirectoryExists(Folder))
     {
         try
         {
             storage.CreateDirectory(Folder);
         }
         catch (Exception)
         {
             return false;
         }
     }
     return true;
 }
コード例 #12
0
        /// <summary>
        /// delete files in directory
        /// </summary>
        /// <param name="storageFolder"></param>
        /// <param name="directory"></param>
        private static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
        {
            if (storageFolder.DirectoryExists(directory))
            {
                try
                {
                    string[] files = storageFolder.GetFileNames(directory);

                    foreach (string file in files)
                    {
                        storageFolder.DeleteFile(directory + file);
                    }
                }
                catch (Exception)
                {
                    // could be in use
                }
            }
        }
コード例 #13
0
        public static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
        {
            if (storageFolder.DirectoryExists(directory))
            {
                try
                {
                    string[] files = storageFolder.GetFileNames(directory);
                    foreach (string File in files)
                    {
                        storageFolder.DeleteFile(directory + files);

                    }
                }
                catch (Exception)
                {
                    //ignoring the exception
                }
             }
        }
コード例 #14
0
ファイル: LogFile.cs プロジェクト: SNSB/DiversityMobile
        private static Stream OpenLogFile(IsolatedStorageFile store)
        {
            if (Profile == null)
            {
                return Stream.Null;
            }

            try
            {
                var fileName = string.Format(LOGFILE_TEMPLATE, DateTime.UtcNow.ToString("yyyy-MM-dd"));
                var folderPath = Path.Combine(Profile.CurrentProfilePath(), LOGFOLDER);

                if (!store.DirectoryExists(folderPath))
                {
                    store.CreateDirectory(folderPath);
                }

                var filePath = Path.Combine(folderPath, fileName);

                if (store.FileExists(filePath))
                {
                    return store.OpenFile(filePath, FileMode.Append);
                }
                else
                {
                    CleanupLogs(store, folderPath);

                    return store.OpenFile(filePath, FileMode.Create);
                }
            }
            catch (Exception ex)
            {
                // Logging Failed, don't kill the process because of it
                Debugger.Break();

                return Stream.Null;
            }
        }
コード例 #15
0
        /// <summary>
        /// 保存信息至本地文件,SilverLight缓存中
        /// </summary>
        /// <param name="rFileName">存储文件名</param>
        /// <param name="rText">消息文本</param>
        public static void WriteSlTextFile(string rFileName, string rText)
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isf = null;
            System.IO.Stream     stream = null;
            System.IO.TextWriter writer = null;
            try
            {
                isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                if (rFileName.IndexOf(':') >= 0)
                {
                    rFileName = rFileName.Substring(rFileName.LastIndexOf(':') + 1);
                }
                string rPath = System.IO.Path.GetDirectoryName(rFileName);
                if (isf.DirectoryExists(rPath) == false)
                {
                    isf.CreateDirectory(rPath);
                }
                stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream(rFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, isf);
                //stream.Seek(0, System.IO.SeekOrigin.End);
                writer = new System.IO.StreamWriter(stream);
                writer.Write(rText);

                writer.Flush();
            }
            finally
            {
                try
                {
                    writer.Close();
                    stream.Close();
                    isf.Dispose();
                }
                catch
                {
                }
            }
        }
コード例 #16
0
ファイル: StoragePhone7.cs プロジェクト: msachs/TestRepo2
        public void CopyDirectory(string sourcePath, string destinationPath, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(sourcePath))
            return;

              var folders = iso.GetDirectoryNames(sourcePath + "/" + "*.*");

              foreach (var folder in folders)
              {
            string sourceFolderPath = sourcePath + "/" + folder;
            string destinationFolderPath = destinationPath + "/" + folder;

            iso.CreateDirectory(destinationFolderPath);
            CopyDirectory(sourceFolderPath, destinationFolderPath, iso);
              }

              foreach (var file in iso.GetFileNames(sourcePath + "/" + "*.*"))
              {
            string sourceFilePath = sourcePath + "/" + file;
            string destinationFilePath = destinationPath + "/" + file;

            iso.CopyFile(sourceFilePath, destinationFilePath);
              }
        }
コード例 #17
0
ファイル: StoragePhone7.cs プロジェクト: msachs/TestRepo2
        private void DeleteDirectory(string path, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(path))
            return;

              var folders = iso.GetDirectoryNames(path + "/" + "*.*");

              foreach (var folder in folders)
              {
            string folderPath = path + "/" + folder;
            DeleteDirectory(folderPath, iso);
              }

              foreach (var file in iso.GetFileNames(path + "/" + "*.*"))
              {
            iso.DeleteFile(path + "/" + file);
              }

              if (path != "")
            iso.DeleteDirectory(path);
        }
コード例 #18
0
        private static string PrepareFilePath(DownloadItemDataModel item, IsolatedStorageFile storage)
        {
            if (item.BookID == Guid.Empty || !storage.DirectoryExists(item.BookID.ToString()))
            {
                item.BookID = CreateFolder(storage);
            }

            var bookPath = CreateBookPath(item);
            if (storage.FileExists(bookPath))
            {
                storage.DeleteFile(bookPath);
            }

            return bookPath;
        }
コード例 #19
0
ファイル: IsoStoreProvider.cs プロジェクト: sawilde/AgFx
            public static void EnsurePath(IsolatedStorageFile store, string filename)
            {
                for (string path = Path.GetDirectoryName(filename);
                            path != "";
                            path = Path.GetDirectoryName(path)) {

                    if (!store.DirectoryExists(path)) {
                        store.CreateDirectory(path);
                    }
                }
            }
コード例 #20
0
        private bool ExtractFile(StreamResourceInfo xapStream, IsolatedStorageFile isf, string fileName)
        {
            try
            {
                if (!isf.DirectoryExists("Temp"))
                    isf.CreateDirectory("Temp");
                if (!isf.DirectoryExists(IsoTempFolderPath))
                    isf.CreateDirectory(IsoTempFolderPath);

                var streamResource = Application.GetResourceStream(xapStream, new Uri(fileName, UriKind.Relative));

                if (streamResource == null)
                    return false;

                string shortFileName = ShortenFileName(fileName);

                var fs = new IsolatedStorageFileStream(IsoTempFolderPath + "\\" + shortFileName, FileMode.Create, isf);

                Byte[] bytes = new Byte[streamResource.Stream.Length];
                streamResource.Stream.Read(bytes, 0, bytes.Length);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();

                streamResource.Stream.Close();
                return true;
            }
            catch (Exception ex)
            {
            }
            return false;
        }
コード例 #21
0
ファイル: FsBitmapCache.cs プロジェクト: arakuma/wp_imagetool
 /// <summary>
 /// 确保Cache文件夹存在
 /// </summary>
 private void EnsureCacheFolder()
 {
     using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) {
         if ( !_storage.DirectoryExists( CACHE_FOLDER ) ) {
             _storage.CreateDirectory( CACHE_FOLDER );
         }
     }
 }
コード例 #22
0
ファイル: DatabaseInfo.cs プロジェクト: gkardava/WinPass
        /// <summary>
        /// Saves user password.
        /// </summary>
        /// <param name="store">The store.</param>
        /// <param name="xml">The XML.</param>
        private async void Save(IsolatedStorageFile store,
            DbPersistentData xml)
        {
            if (!store.DirectoryExists(Folder))
                store.CreateDirectory(Folder);

            using (var fs = store.CreateFile(ProtectionPath))
            {
                var protect = xml.Protection;
                fs.Write(protect, 0, protect.Length);
            }
            using (var fs = store.CreateFile(ParsedXmlPath))
            using (var buffer = new MemoryStream(xml.Xml))
                BufferEx.CopyStream(buffer, fs);

            using (var fs = store.CreateFile(MasterPasswordPath))
            {
                var data = xml.MasterKey;
                await fs.WriteAsync(data, 0, data.Length);

            }
        }
コード例 #23
0
        private static string PrepareFilePath(Book item, IsolatedStorageFile storage)
        {
            if (item.IsMyBook || item.IsFreeBook)
            {
                if (!storage.DirectoryExists(item.Id.ToString()))
                {
                    storage.CreateDirectory(Path.Combine(CatalogPath, item.Id.ToString()));
                }
            }
            else
            {
                if (!storage.DirectoryExists(item.Id + ".trial"))
                {
                    storage.CreateDirectory(Path.Combine(CatalogPath, item.Id + ".trial"));
                }
            }

            var bookPath = item.IsMyBook || item.IsFreeBook ? CreateBookPath(item.Id.ToString()) : CreateBookPath(item.Id + ".trial");
            if (storage.FileExists(bookPath))
            {
                storage.DeleteFile(bookPath);
            }

            return bookPath;
        }
コード例 #24
0
 public void MoveOldCrashlogsIfNeeded(IsolatedStorageFile store)
 {
     try
     {
         if (store.DirectoryExists(Constants.OldCrashDirectoryName))
         {
             var files = store.GetFileNames(Path.Combine(Constants.OldCrashDirectoryName, Constants.CrashFilePrefix + "*.log"));
             if (files.Length > 0)
             {
                 if (!store.DirectoryExists(Constants.CrashDirectoryName))
                 {
                     store.CreateDirectory(Constants.CrashDirectoryName);
                 }
                 foreach (var fileName in files)
                 {
                     store.MoveFile(Path.Combine(Constants.OldCrashDirectoryName, Path.GetFileName(fileName)), Path.Combine(Constants.CrashDirectoryName, Path.GetFileName(fileName)));
                 }
                 if (store.GetFileNames(Path.Combine(Constants.OldCrashDirectoryName, Constants.CrashFilePrefix + "*.*")).Length == 0)
                 {
                     store.DeleteDirectory(Constants.OldCrashDirectoryName);
                 }
             }
         }
     }
     catch (Exception e)
     {
         HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
     }
 }
コード例 #25
0
 private static void CreateDirIfNecessary(IsolatedStorageFile iso, string dir)
 {
     if (!iso.DirectoryExists(dir))
     {
         iso.CreateDirectory(dir);
     }
 }
 /// <summary>
 /// Verifies whether or not a given directory exists in IsolatedStorage
 /// </summary>
 /// <param name="directorypath">The path to a given directory</param>
 /// <param name="storage">A reference to a valid IsolatedStorageFile instance.</param>
 /// <returns>True if the directory exists, false otherwise.</returns>
 public static bool DirectoryExists(string directorypath, IsolatedStorageFile storage)
 {
     return storage.DirectoryExists(directorypath);
 }
コード例 #27
0
 // helper function from: http://stackoverflow.com/questions/18422331/easy-way-to-recursively-delete-directories-in-isolatedstorage-on-wp7-8
 private void DeleteDirectoryRecursively(IsolatedStorageFile storageFile, String dirName)
 {
     try
     {
         String pattern = dirName + @"\*";
         String[] files = storageFile.GetFileNames(pattern);
         foreach (var fName in files)
         {
             storageFile.DeleteFile(Path.Combine(dirName, fName));
         }
         String[] dirs = storageFile.GetDirectoryNames(pattern);
         foreach (var dName in dirs)
         {
             DeleteDirectoryRecursively(storageFile, Path.Combine(dirName, dName));
         }
         if (storageFile.DirectoryExists(dirName))
         {
             storageFile.DeleteDirectory(dirName);
         }
     }
     catch(Exception e)
     {
         Debug.WriteLine("Unable to delete directory : " + dirName);
     }
 }
コード例 #28
0
 private static void TryToDeleteAllFiles( IsolatedStorageFile storagefolder, string Directory) {
     if (storagefolder.DirectoryExists(Directory))
     {
         try
         {
             string[] files = storagefolder.GetFileNames(Directory);
             foreach (var item in files)
             {
                 storagefolder.DeleteFile(Directory+item); 
             }
         }
         catch (Exception)
         {
             //In Use
             throw;
         }
     }
 
 }
コード例 #29
0
ファイル: MainPage.xaml.cs プロジェクト: ackratos/USTCMap
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            this.lat = 0.0;
            this.lon = 0.0;
            this.zoomlevel = MIN_ZOOM_LEVEL;
            this.targetZoomLevel = 19;
            this.scale = 1;
            this.threshold = getDPI() * 0.06f;

            this.hasTarget = false;
            this.isTracking = false;
            this.hasPosition = false;

            plotterHelper = new PlotterHelper();
            westCampus = new iustc.map.data.Rectangle(31.836497, 31.844080, 117.245445, 117.255058);
            eastCamput = new iustc.map.data.Rectangle(31.834236, 31.844189, 117.258920, 117.267889);
            arrowUri = new Uri("/iUSTCMap;component/resources/map_location_arrow.png", UriKind.Relative);
            dotUri = new Uri("/iUSTCMap;component/resources/map_location_dot.png", UriKind.Relative);
            arrowBitmap = new BitmapImage(arrowUri);
            dotBitmap = new BitmapImage(dotUri);

            if (cm == null)
                cm = new CacheManager(CACHE_CAPACITY, this);
            if (pThread == null)
                pThread = new PlotterThread(cm);

            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy

            LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 236, 236, 236));

            isoFile = IsolatedStorageFile.GetUserStoreForApplication();
            if (!isoFile.DirectoryExists("cache"))
            {
                isoFile.CreateDirectory("cache");
            }
            #region appBar
            appBar = new ApplicationBar();
            appBar.Opacity = 0.5;
            locateButton = new ApplicationBarIconButton(new Uri("resources/appbar.locate.rest.png", UriKind.Relative));
            locateButton.Text = "定位";
            locateButton.Click += new EventHandler(locateButton_Click);
            appBar.Buttons.Add(locateButton);

            zoomInButton = new ApplicationBarIconButton(new Uri("resources/appbar.new.rest.png", UriKind.Relative));
            zoomInButton.Text = "放大";
            zoomInButton.Click += new EventHandler(zoomInButton_Click);
            appBar.Buttons.Add(zoomInButton);

            zoomOutButton = new ApplicationBarIconButton(new Uri("resources/appbar.minus.rest.png", UriKind.Relative));
            zoomOutButton.Text = "缩小";
            zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
            appBar.Buttons.Add(zoomOutButton);

            selectCampusButton = new ApplicationBarIconButton(new Uri("resources/appbar.east.rest.png", UriKind.Relative));
            selectCampusButton.Text = "东校区";
            selectCampusButton.Click += new EventHandler(selectCampusButton_Click);
            appBar.Buttons.Add(selectCampusButton);

            ApplicationBar = appBar;
            #endregion
        }
コード例 #30
0
ファイル: Storage.cs プロジェクト: prabuddha1987/NuGenBioChem
 static Storage()
 {
     storage = IsolatedStorageFile.GetUserStoreForAssembly();
     if (!storage.DirectoryExists(rootDirectory)) storage.CreateDirectory(rootDirectory);
 }
コード例 #31
0
ファイル: File.cs プロジェクト: Zougi/liny_gap
        private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path = File.AddSlashToDirectory(sourceDir);

            bool bExists = isoFile.DirectoryExists(destDir);

            if (!bExists)
            {
                isoFile.CreateDirectory(destDir);
            }

            destDir = File.AddSlashToDirectory(destDir);

            string[] files = isoFile.GetFileNames(path + "*");

            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file, true);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }
コード例 #32
0
ファイル: MainViewModel.cs プロジェクト: slodge/main
        private static void DeleteAllFiles(IsolatedStorageFile isf)
        {
            if (false == isf.DirectoryExists(Constants.MyScriptsDirectoryName))
                return;

            var filesDel = isf.GetFileNames(string.Format("{0}\\*", Constants.MyScriptsDirectoryName));
            foreach (var f in filesDel)
            {
                isf.DeleteFile(Constants.MyScriptsDirectoryName + "\\" + f);
            }
            isf.DeleteDirectory(Constants.MyScriptsDirectoryName);
        }
コード例 #33
0
 public override Task <bool> GetDirectoryExistsAsync(string path)
 {
     return(Task <bool> .Factory.StartNew(() => file.DirectoryExists(path)));
 }