public async Task CopyResource(string resourceName, string targetName, IFolder targetFolder)
        {
            using (Stream resource = typeof(IFileService).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName))
            {
                if (resource == null)
                {
                    throw new ArgumentException("No such resource", "resourceName");
                }

                var file = await targetFolder.CreateFileAsync(targetName, CreationCollisionOption.ReplaceExisting);

                using (var output = await file.OpenAsync(FileAccess.ReadAndWrite))
                {
                    await resource.CopyToAsync(output);
                }
            }
        }
        public async Task StoreEventAsync(InstrumentationEvent instrumentationEvent)
        {
            if (string.IsNullOrEmpty(instrumentationEvent?.ToJson().ToString()))
            {
                LoggingService.Log("Invalid Event", LoggingLevel.Error);
                return;
            }
            if (await ShouldStoreEventAsync().ConfigureAwait(false))
            {
                var fileName = instrumentationEvent.EventId + FilenameSuffix;
                //Open file
                IFile file = await _rootDir.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);

                //Wrtie to file after encrypting contents
                await file.WriteAllTextAsync(Encrypt(instrumentationEvent.ToJson().ToString(), EncryptionKey)).ConfigureAwait(false);
            }
        }
Beispiel #3
0
        public static void Reset()
        {
            try
            {
                IFolder rootFolder = FileSystem.Current.LocalStorage;

                // create a folder, if one does not exist already
                IFolder folder = rootFolder.CreateFolderAsync(GlobalVar.DataFolderName, CreationCollisionOption.OpenIfExists).GetAwaiter().GetResult();

                // create a file, overwriting any existing file
                IFile file = folder.CreateFileAsync(GlobalVar.DataFileName + ".txt", CreationCollisionOption.ReplaceExisting).GetAwaiter().GetResult();

                GlobalVar.DataToSave = new dynamic[] { null, "false" };
            }
            catch (Exception exc)
            { }
        }
Beispiel #4
0
        protected override async void OnStart()
        {
            // Handle when your app starts
            IFolder rootFolder = FileSystem.Current.LocalStorage;

            Debug.WriteLine($"Root Flder name :{rootFolder.Name}");
            Debug.WriteLine($"Root Flder path :{rootFolder.Path}");

            IFolder folder = await rootFolder.CreateFolderAsync("Temp", CreationCollisionOption.OpenIfExists);

            Debug.WriteLine($"Temp Flder name :{folder.Name}");
            Debug.WriteLine($"Temp Flder path :{folder.Path}");

            IFile file = await folder.CreateFileAsync("MyTest.txt", CreationCollisionOption.OpenIfExists);

            await file.WriteAllTextAsync("Hello I'm Jimmy");
        }
Beispiel #5
0
        private async void ReceiveSurveys()
        {
            SurveysServices S_S1        = new SurveysServices();
            ControlFile     controlFile = new ControlFile();
            string          username    = await controlFile.GetUserName();

            S_S1.Set_UrlApi("ReceiveSurveysShared/" + username);
            List <Survey> ReceivedSurveys = await S_S1.GetSurveysAsync();

            ExistenceCheckResult result = await folder.CheckExistsAsync("Receivedsurveys");

            if (result == ExistenceCheckResult.FolderExists)
            {
                folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.OpenIfExists);

                string Content = await file.ReadAllTextAsync();

                List <Survey> OldreceiveSurveys = Serializable_Survey.deserialize(Content).ToList();
                if (OldreceiveSurveys.Count < ReceivedSurveys.Count)
                {
                    var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                    player.Load("NotificationReceive.mp3");
                    player.Play();

                    Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
                }
            }
            else if (result != ExistenceCheckResult.FolderExists && ReceivedSurveys.Count > 0)
            {
                var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                player.Load("NotificationReceive.mp3");
                player.Play();

                Plugin.LocalNotifications.CrossLocalNotifications.Current.Show(Lang.Resource.receivesurveys, Lang.Resource.BodyreceiveSurvey, 0);
            }
            folder = FileSystem.Current.LocalStorage;
            folder = await folder.CreateFolderAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

            file = await folder.CreateFileAsync("Receivedsurveys", CreationCollisionOption.ReplaceExisting);

            string content = Serializable_Survey.serialize(ReceivedSurveys);
            await file.WriteAllTextAsync(content);
        }
        private async void Save(object sender, EventArgs e)
        {
            if (!CheckNetwork.Check_Connectivity())
            {
                return;
            }

            stackQuestions.Opacity      = 0.5;
            ActivityIndicator.IsRunning = true;

            folder = FileSystem.Current.LocalStorage;
            folder = await folder.CreateFolderAsync("foldersurveys" + username, CreationCollisionOption.OpenIfExists);

            file = await folder.CreateFileAsync("filesurveys" + username, CreationCollisionOption.OpenIfExists);

            string content = await file.ReadAllTextAsync();

            ListSurveys = Serializable_Survey.deserialize(content);
            foreach (Survey S in ListSurveys)
            {
                if (S.Id == survey.Id)
                {
                    S.Title_Property       = Title.Text;
                    S.Description_Property = Description.Text;

                    survey = S;
                    SurveysServices S_S = new SurveysServices();
                    S_S.Set_UrlApi("EditSurveys/" + username);
                    await S_S.PutSurveysAsync(survey);

                    break;
                }
            }
            title.Text       = Title.Text;
            description.Text = Description.Text;
            content          = Serializable_Survey.serialize(ListSurveys.ToList());
            await file.WriteAllTextAsync(content);

            Cancel(sender, e);

            await Task.Delay(500);

            ActivityIndicator.IsRunning = false;
            stackQuestions.Opacity      = 1;
        }
Beispiel #7
0
        private async Task ProcessHtmlFile(IFile sourceFile, IFolder outputFolder)
        {
            this.BuildHandler.SignalBuildEvent("Processing HTML file " + sourceFile.Path);

            string rawHtml = await sourceFile.ReadAllTextAsync();

            // Inject the templates
            Dictionary <string, string> values = new Dictionary <string, string>();
            string outputHtml = null;

            this.TemplateServices.InjectTemplateRecursive(rawHtml, this.Templates, out outputHtml, ref values);

            // Inject template values
            outputHtml = this.TemplateServices.InjectTemplateValues(outputHtml, values);

            // Write out the processed html to the output folder
            await outputFolder.CreateFileAsync(sourceFile.Name, outputHtml);
        }
Beispiel #8
0
        public static async Task <string> GetPathForFile(string filename)
        {
            System.Diagnostics.Debug.WriteLine("Core.GetPathForFile()");

            // get hold of the file system
            IFolder rootFolder = FileSystem.Current.LocalStorage;

            // create a folder if one does not exist already
            IFolder folder = await rootFolder.CreateFolderAsync(folderName, CreationCollisionOption.OpenIfExists);

            // create a file if one does not exist already
            IFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.OpenIfExists);

            System.Diagnostics.Debug.WriteLine("Path for file: " + file.Path);

            // get path
            return(file.Path);
        }
    public async Task PCLGenaratePdf(string path)
    {
        IFolder rootFolder = await FileSystem.Current.GetFolderFromPathAsync(path);

        IFolder folder = await rootFolder.CreateFolderAsync("folder", CreationCollisionOption.OpenIfExists);

        IFile file = await folder.CreateFileAsync("file.pdf", CreationCollisionOption.ReplaceExisting);

        using (var fs = await file.OpenAsync(FileAccess.ReadAndWrite))
        {
            var       document = new Document(PageSize.A4, 25, 25, 30, 30);
            PdfWriter writer   = PdfWriter.GetInstance(document, fs);
            document.Open();
            document.Add(new Paragraph("heloo everyone"));
            document.Close();
            writer.Close();
        }
    }
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        /// <remarks>When saving, this method ignores null values to reduce file size.</remarks>
        public override async Task <bool> SyncAsync()
        {
            //RWM: Serialize the table to a file.
            if (localCacheFolder == null)
            {
                //RWM: Shouldn't happen but better safe than sorry.
                localCacheFolder = await FileSystem.Current.LocalStorage.CreateFolderAsync(CacheFolderName, CreationCollisionOption.OpenIfExists);
            }
            if (localCacheFile == null)
            {
                //RWM: Shouldn't happen but better safe than sorry.
                localCacheFile = await localCacheFolder.CreateFileAsync(CacheFileName, CreationCollisionOption.ReplaceExisting);
            }
            var contents = JsonConvert.SerializeObject(items, Formatting.None, jsonIgnoreNullsSettings);
            await localCacheFile.WriteAllTextAsync(contents);

            return(true);
        }
        public static async Task AppendLineToFileAsync(string fileName, string line)
        {
            try
            {
#if UWP
                var folder = ApplicationData.Current.LocalFolder;
                var file   = await folder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);

                await FileIO.AppendLinesAsync(file, new List <string>() { line });
#else
                IFolder folder = FileSystem.Current.LocalStorage;
                IFile   file   = await folder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);

                await file.AppendAllLinesAsync(new List <string>() { line });
#endif
            }
            catch { /* Avoid any exception at this point. */ }
        }
Beispiel #12
0
 public MainPageViewModel(INavigationService navigationService)
 {
     _navigationService = navigationService;
     LogoutCommand      = new DelegateCommand(async() =>
     {
         IFolder fooFolder = await PCLStorage.FileSystem.Current.LocalStorage.
                             CreateFolderAsync("MyData", CreationCollisionOption.OpenIfExists);
         IFile fooFile = await fooFolder.CreateFileAsync("UserInfo.txt", CreationCollisionOption.OpenIfExists);
         var fooItem   = new UserInfo()
         {
             ID   = "",
             Name = ""
         };
         var fooJSON = JsonConvert.SerializeObject(fooItem);
         await fooFile.WriteAllTextAsync(fooJSON);
         _navigationService.NavigateAsync("/LoginPage");
     });
 }
        async protected override void OnAppearing()
        {
            base.OnAppearing();

            IFolder rootfolder = FileSystem.Current.LocalStorage;

            Debug.WriteLine($"rootfolder Name:{rootfolder.Name}");
            Debug.WriteLine($"rootfolder Paht:{rootfolder.Path}");

            IFolder folder = await rootfolder.CreateFolderAsync("temp", CreationCollisionOption.OpenIfExists);

            Debug.WriteLine($"folder Name:{folder.Name}");
            Debug.WriteLine($"folder Paht:{folder.Path}");

            IFile file = await folder.CreateFileAsync("MyTest.txt", CreationCollisionOption.OpenIfExists);

            await file.WriteAllTextAsync("Hello Ming");
        }
        public async Task SaveToLocal()
        {
            try
            {
                IFolder rootFolder = FileSystem.Current.LocalStorage;
                IFolder folder     = await rootFolder.CreateFolderAsync("RMMT",
                                                                        CreationCollisionOption.OpenIfExists);

                IFile file = await folder.CreateFileAsync("", CreationCollisionOption.ReplaceExisting);

                await file.WriteAllTextAsync("42");
            }
            catch (Exception)
            {
                _commonFun.AlertLongText("操作异常,请重试。-->LocalRegistScoreViewModel");
                return;
            }
        }
Beispiel #15
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var rootFolder = FileSystem.Current.LocalStorage;

            _localFolder = await rootFolder.CreateFolderAsync(FOLDER, CreationCollisionOption.OpenIfExists);

            _localFile = await _localFolder.CreateFileAsync(FILE, CreationCollisionOption.OpenIfExists);

            var result = "";

            result = await _localFile.ReadAllTextAsync();

            if (result.Length > 0)
            {
                FillListView(result);
            }
        }
Beispiel #16
0
        public async Task Initialize()
        {
            try
            {
                IFolder rootFolder = FileSystem.Current.LocalStorage;
                IFolder folder     = rootFolder.CreateFolderAsync("app-settings", CreationCollisionOption.OpenIfExists).Result;

                // following call made sync to aviod deadlocks
                this.file = folder.CreateFileAsync(configFile, CreationCollisionOption.OpenIfExists).Result;

                this.isInitialized = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                await Task.Delay(300);
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                IFolder rootFolder = FileSystem.Current.LocalStorage;
                IFolder folder     = await rootFolder.CreateFolderAsync("DolentaCache", CreationCollisionOption.OpenIfExists);

                string fileName = "favourites.txt";
                IFile  file     = await folder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);

                string content = await file.ReadAllTextAsync();

                List <Offer> Favs = new List <Offer>();
                try
                {
                    Favs = JsonConvert.DeserializeObject <List <Offer> >(content);
                }
                catch (System.NullReferenceException)
                {
                    Console.WriteLine("Nie bylo");
                    Favs = new List <Offer>();
                }
                foreach (Offer temp in Favs)
                {
                    Items.Add(temp);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private async Task OnGetImage()
        {
            var settings = new ImageConstructionSettings
            {
                Padding            = 12,
                StrokeColor        = Color.FromRgb(25, 25, 25),
                BackgroundColor    = Color.FromRgb(225, 225, 225),
                DesiredSizeOrScale = 2f
            };
            var image = await padView.GetImageStreamAsync(SignatureImageFormat.Png, settings);

            if (image == null)
            {
                return;
            }



            IFolder rootFolder = FileSystem.Current.LocalStorage;
            IFolder folder     = await rootFolder.CreateFolderAsync("MySubFolder",
                                                                    CreationCollisionOption.OpenIfExists);

            IFile file = await folder.CreateFileAsync("answer.png",
                                                      CreationCollisionOption.ReplaceExisting);

            using (var fooStream = await file.OpenAsync(FileAccess.ReadAndWrite))
            {
                await image.CopyToAsync(fooStream);
            }



            //var page = new ContentPage
            //{
            //    Title = "Signature",
            //    Content = new Image
            //    {
            //        Aspect = Aspect.AspectFit,
            //        Source = ImageSource.FromStream(() => image)
            //    }
            //};

            //await Navigation.PushAsync(page);
        }
Beispiel #19
0
        public async void WriteFileLocally(MemoryStream imageStream, string filename,
                                           CallbackOnFinished callbackOnFinished)
        {
            IFolder localFolder = FileSystem.Current.LocalStorage;
            IFile   localFile   = null;

            localFolder = await localFolder.CreateFolderAsync(localFolderName,
                                                              CreationCollisionOption.OpenIfExists);

            bool fileCreated = false;
            int  counter     = 0;

            while (!fileCreated)
            {
                try {
                    filename += ".jpg";
                    localFile = await localFolder.CreateFileAsync(filename,
                                                                  CreationCollisionOption.FailIfExists);

                    fileCreated = true;
                }
                catch (Exception e) {
                    //file exists
                    counter++;
                    filename = StorageUtility.UpdateFilename(filename, counter);
                }
            }

            using (Stream stream = await localFile.OpenAsync(FileAccess.ReadAndWrite)) {
                imageStream.Position = 0;
                imageStream.CopyTo(stream);
                stream.Flush();
            }

            bool sendingResult = await SendFilePicToServer(localFile.Path, "file");

            if (sendingResult)
            {
                await localFile.DeleteAsync();
            }

            //chiamare la callback operazione conclusa
            callbackOnFinished();
        }
        public static async Task <string> CopyTodoItemFileAsync(string itemId, string filePath)
        {
            IFolder localStorage = FileSystem.Current.LocalStorage;

            string fileName   = Path.GetFileName(filePath);
            string targetPath = await GetLocalFilePathAsync(itemId, fileName);

            var sourceFile = await localStorage.GetFileAsync(filePath);

            var sourceStream = await sourceFile.OpenAsync(FileAccess.Read);

            var targetFile = await localStorage.CreateFileAsync(targetPath, CreationCollisionOption.ReplaceExisting);

            using (var targetStream = await targetFile.OpenAsync(FileAccess.ReadAndWrite)) {
                await sourceStream.CopyToAsync(targetStream);
            }

            return(targetPath);
        }
Beispiel #21
0
        public static async Task <bool> CreateEmptyFileInFolder(string folderName, string filename)
        {
            bool result = true;

            try {
                IFolder localFolder = FileSystem.Current.LocalStorage;
                localFolder = await localFolder.CreateFolderAsync(folderName,
                                                                  CreationCollisionOption.OpenIfExists);

                IFile localFile = await localFolder.CreateFileAsync(filename,
                                                                    CreationCollisionOption.FailIfExists);
            }
            catch (Exception e) {
                result = false;
                Debug.WriteLine(e.StackTrace);
            }

            return(result);
        }
Beispiel #22
0
        async Task WriteXmlResultFile(ResultSummary result)
        {
            string outputFolderName    = Path.GetDirectoryName(Options.ResultFilePath);
            string outputXmlReportName = Path.GetFileName(Options.ResultFilePath);

            await CreateFolderRecursive(outputFolderName);

            IFolder outputFolder =
                await FileSystem.Current.GetFolderFromPathAsync(outputFolderName, CancellationToken.None);

            IFile xmlResultFile =
                await outputFolder.CreateFileAsync(outputXmlReportName, CreationCollisionOption.ReplaceExisting);

            using (var resultFileStream = new StreamWriter(await xmlResultFile.OpenAsync(FileAccess.ReadAndWrite)))
            {
                var xml = result.GetTestXml().ToString();
                await resultFileStream.WriteAsync(xml);
            }
        }
        public async void ShareReport()
        {
            IFileSystem fileSystem    = FileSystem.Current;
            IFolder     rootFolder    = fileSystem.LocalStorage;
            IFolder     reportsFolder = await rootFolder.CreateFolderAsync("reports", CreationCollisionOption.OpenIfExists);

            var txtFile = await reportsFolder.CreateFileAsync("report.txt", CreationCollisionOption.ReplaceExisting);

            using (StreamWriter sw = new StreamWriter(txtFile.Path))
            {
                foreach (var ce in CategoryExpensesCollection)
                {
                    sw.WriteLine($"{ce.Category} - {ce.ExpensesPercentage:p}");
                }
            }

            IShare shareDependency = DependencyService.Get <IShare>();
            await shareDependency.Show("Expense Report", "Here is your expenses report", txtFile.Path);
        }
 public static async Task Copy(IFolder source, IFolder target)
 {
     foreach (IFolder f in await source.GetFoldersAsync())
     {
         if (f.Name.StartsWith("."))
         {
             continue;
         }
         await Copy(f, await target.CreateFolderAsync(f.Name, CreationCollisionOption.GenerateUniqueName).ConfigureAwait(false)).ConfigureAwait(false);
     }
     foreach (IFile f in await source.GetFilesAsync())
     {
         if (f.Name.StartsWith("."))
         {
             continue;
         }
         await Copy(f, await target.CreateFileAsync(f.Name, CreationCollisionOption.GenerateUniqueName).ConfigureAwait(false)).ConfigureAwait(false);
     }
 }
Beispiel #25
0
        public async Task WriteAndReadFile()
        {
            //	Arrange
            IFolder folder = TestFileSystem.LocalStorage;
            IFile   file   = await folder.CreateFileAsync("readWriteFile.txt", CreationCollisionOption.FailIfExists);

            string contents = "And so we beat on, boats against the current, born back ceaselessly into the past.";

            //	Act
            await file.WriteAllTextAsync(contents);

            string readContents = await file.ReadAllTextAsync();

            //	Assert
            Assert.AreEqual(contents, readContents);

            //	Cleanup
            await file.DeleteAsync();
        }
Beispiel #26
0
        public async Task OpenFileForReadAndWrite()
        {
            //  Arrange
            IFolder folder   = TestFileSystem.LocalStorage;
            string  fileName = "fileToOpenForReadAndWrite";
            IFile   file     = await folder.CreateFileAsync(fileName, CreationCollisionOption.FailIfExists);

            //  Act
            using (Stream stream = await file.OpenAsync(FileAccess.ReadAndWrite))
            {
                //  Assert
                Assert.IsTrue(stream.CanWrite);
                Assert.IsTrue(stream.CanRead);
                Assert.IsTrue(stream.CanSeek);
            }

            //  Cleanup
            await file.DeleteAsync();
        }
Beispiel #27
0
        public async Task <bool> CreateReport(string name)
        {
            try
            {
                IFolder rootFolder = FileSystem.Current.LocalStorage;
                folder = await rootFolder.CreateFolderAsync("Reports",
                                                            CreationCollisionOption.OpenIfExists).ConfigureAwait(false);

                file = await folder.CreateFileAsync(name,
                                                    CreationCollisionOption.ReplaceExisting);

                //await file.WriteAllTextAsync("42");
            } catch (Exception ex)
            {
                throw new Exception("Error with file creation: " + ex.Message);
            }

            return(await Task.FromResult(true));
        }
Beispiel #28
0
        public bool CreateFile(string fileName, string content)
        {
            if (LogFolder == null)
            {
                return(false);
            }

            // ToDo: change default document path: /data/user/0/uwgb.dylanhoffman.m_obd_2/files/MOBD2_LOGS/"filename"
            try
            {
                LogFile = LogFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting).Result;
                LogFile.WriteAllTextAsync(content);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public async Task <IFile> GetFileFromFolder(string folderName, string fileName)
        {
            // Bu method ile klasörden dosya çağırıyoruz. CreationCollisionOption durumlarından OpenIfexits seçili eğer dosya var ise dosyayı dönüyor.
            IFolder rootFolder = FileSystem.Current.LocalStorage;
            var     exits      = await FolderExists(folderName);

            if (exits)
            {
                IFolder requestedFolder = await rootFolder.GetFolderAsync(folderName);

                IFile requestedFile = await requestedFolder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);

                return(requestedFile);
            }
            else
            {
                return(null);
            }
        }
Beispiel #30
0
        internal static async Task <string> ReadFileAsync(IFolder rootFolder)
        {
            //IFolder rootFolder = FileSystem.Current.LocalStorage;
            //IFolder folder = await rootFolder.GetFolderAsync(Constants.StorageSubFolder);
            // create a folder, if one does not exist already
            IFolder folder = await rootFolder.CreateFolderAsync(Constants.StorageSubFolder, CreationCollisionOption.OpenIfExists);

            if (folder == null)
            {
                return(null);
            }
            // create a file, overwriting any existing file
            IFile file = await folder.CreateFileAsync(Constants.StorageFileName, CreationCollisionOption.OpenIfExists);

            //IFile file = await folder.GetFileAsync(Constants.StorageFileName);
            var contents = await file.ReadAllTextAsync();

            return(contents);
        }
 public static async Task<bool> DownloadFileAsync(IFolder folder, string url, string fileName)
 {
     using (var client = new HttpClient())
     using (var response = await client.GetAsync(url))
     {
         if (response.StatusCode == System.Net.HttpStatusCode.OK)
         {
             Stream temp = await response.Content.ReadAsStreamAsync();
             IFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
             using (var fs = await file.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
             {
                 await temp.CopyToAsync(fs);
                 fs.Close();
                 return true;
             }
         }
         else
         {
             Debug.WriteLine("NOT FOUND " + url);
             return false;
         }
     }
 }
Beispiel #32
0
        public static async Task<IFile> CreateFileAsync(string path, IFolder folder,
            CreationCollisionOption option = CreationCollisionOption.OpenIfExists)
        {
            if (path.StartsWith("/") || path.StartsWith("\\"))
                path = path.Substring(1);
            var parts = path.Split('/');

            var fileName = parts.Last();

            if (parts.Length > 1)
            {
                folder =
                    await
                        EnsureFolderExistsAsync(path.Substring(0, path.Length - fileName.Length), folder)
                            .DontMarshall();
            }

            return await folder.CreateFileAsync(fileName, option).DontMarshall();
        }
Beispiel #33
0
        public async void createCleanFileSystem(IFolder fileSystem)
        {

            IFile file = await fileSystem.CreateFileAsync("PhoneData.txt", CreationCollisionOption.ReplaceExisting);
            string baseString = "a\nUVA,\n";   ///GOTO: settings page if this is modified
            await file.WriteAllTextAsync(baseString);
            var navPage = new NavigationPage(new CarouselTutorialPage());
            MainPage = navPage;
        }
Beispiel #34
0
        public async void createFileSystem(IFolder fileSystem)
        {
            var loc = await App.dbWrapper.GetLocation();
            var cloudList = await App.dbWrapper.GetAvailableClouds(loc[0], loc[1]);
            string cloudNamesString = "";
            for(int i =0; i<cloudList.Count; i++)
            {
                cloudNamesString +=(cloudList[i].Title) + ",";
                System.Diagnostics.Debug.WriteLine(cloudList[i].Title);

            }
            IFile file = await fileSystem.CreateFileAsync("PhoneData.txt", CreationCollisionOption.ReplaceExisting);
            string baseString = "a\nUVA,"+cloudNamesString+"\n";   ///GOTO: settings page if this is modified
            await file.WriteAllTextAsync(baseString);
            var navPage = new NavigationPage(new CarouselTutorialPage());
            MainPage = navPage;
        }