private static async Task AddFileToRemoteFolderAsync(string content, ResourceInfo resourceInfo) { await AddFileToFolderAsync(_remoteResourceFolder, content, resourceInfo); }
private static async Task AddFileToFolderAsync(IFolder folder, string content, ResourceInfo resourceInfo) { var fullFilePath = Path.Combine(folder.Path, resourceInfo.RelativePath); var file = await PathHelper.GetOrCreateFileAsync(fullFilePath); await file.WriteAllTextAsync(content); var indexFile = await folder.GetFileAsync("index.txt"); var indexData = await indexFile.ReadAllTextAsync(); var resourceInfos = JsonConvert.DeserializeObject <List <ResourceInfo> >(indexData); var neededResourceInfo = resourceInfos.SingleOrDefault(x => x.RelativePath == resourceInfo.RelativePath); if (neededResourceInfo != null) { resourceInfos.Remove(neededResourceInfo); } resourceInfos.Add(resourceInfo); var serializedIndexData = JsonConvert.SerializeObject(resourceInfos); await indexFile.WriteAllTextAsync(serializedIndexData); }
private static async Task AddFileToCompiledFolderAsync(string content, ResourceInfo resourceInfo) { await AddFileToFolderAsync(_compiledResourceFolder, content, resourceInfo); }