Are there any easy Read/write to file system from Metro Apps when the files are in nested folders - microsoft-metro

I'm working on a application that downloads some files to the local storage for caching. The files online are sometimes in 3 or 4 nested folders and I would like to also keep this hierarchy in my cache folder.
Is there no easy way other then having to (await (await folder.GetFolderAsync("dir1")).GetFolderAsync("dir2)) and so on? Now it's hardcoded with dir1 and dir2.
What's the easiest way when the file path is a string like "MyFolder/OtherFolder/lastFolder/file.xml"?

The static member function StorageFolder::GetFolderFromPathAsync can be used to get a StorageFolder object for a folder given its path.

Related

[IO.Compression.ZipFile]::CreateFromDirectory() include directory in archive

I need to compress and extract some zip files with a rather large source, often 30GB or more, so I can't use the native PowerShell cmdlets. I am looking at using [IO.Compression.ZipFile] static methods, and liking the fact that it works with big source folders, and works faster in general. But I am running into one issue. I want to include the source folder IN the archive, like Compress-Archive does
$sourcePath = '\\px\Rollouts\ADSK\2023\Revit_2023\Deployment\Revit_2023'
Compress-Archive -Path:$sourcePath -DestinationPath:$zipPath
the Revit_2023 folder is part of the archive, while with
[IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipPath)
only the CONTENTS of the Revit_2023 folder is archived. When extracting I could create a folder with the name of the Zip file as the folder name and extract to that, but I can imagine a scenario where I really want the Zip file named differently, perhaps with a date or something. But in looking at the docs here it looks like this behavior is the only option for a simple implementation, and doing what I want to do is going to require managing entries myself. And even that I am not sure about, since it looks like entries are files only? Am I misunderstanding here, and there is an option to include the source folder? I sure would prefer to have a simple solution AND the source folder name in the archive.
Overloads of the method are:
static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName)
static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory)
static void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding entryNameEncoding)
So the command would be:
[IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipPath, [System.IO.Compression.CompressionLevel]::Optimal, $true)
You could pick different CompressionLevel, but you can't skip it when also using includeBaseDirectory flag.

How to get the extreme root directory of a storage in Flutter?

I am currently using "path_provider package" of Flutter for getting the desired directories.
But as far as I am aware about this package. It only provides path to specific directories like :
TempDirectory.
AppLibraryDirectory.
etc ......
But what if I want a custom path ..... like the extreme root directory of a storage.( Whose child will be internal memory an sdcard kindoff). How can I get the path of this directory ? I thought of hardcoding specific paths like this one manually in my project but then won't the names of the directories vary based on the device manufacturer ?
I thought getExternalStorageDirectory() function might provide me the extreme root of external storage. But it provided me with this instead.
"/storage/emulated/0/Android/data/com.example.file_test/files".
when I wanted something like this : "/storage".
How can I do this ?
Thankyou for answering in advance.

How can I rename file uploaded to s3 using javascript api?

'pickAndStore' method allows me to specify full path to the file, but I don't know it's extension at this point (file path has to be defined before file is uploaded, so it's not possible to provide a path with correct extension).
if I use 'pick' and then 'store' I have 2 files (because both methods uploads file to the s3). I can delete 'old' file, but it's not optimal and can be pain (take ages) with really big files.
Is there any better solution? Ideally to rename existing file.
Currently, there is no workaround for renaming file.
However, in our Javascript API v2 we are planing to add new callback function. onStart callback will be fired after user pick file but before file uploading. There could be option like renaming file based on original filename.
We will keep you updated.

How to list out all the files in the public/images directory in a Play Framework 2 Scala application?

I want to list out all the file names in the public/images directory for my Scala Play Framework 2 application so that the Play Application just lists those file names to the HTML page. How can this be done?
Is there a right way to access the public/images directory to read files or list the directory? I don't want to use absolute directory paths.
There is method getFile(relateivePath: String): File on Play object and also in the Application class which returns file relative to application root directory. In your case:
Play.getFile("public/images")
return File object, which represent public/images/directory. You can call list or listFiles on it to get contents of the directory.

addToFolder(): The copy version of the file is deleted, if the original version is deleted

I started doing development with google scripts few days ago and recently joined stackoverflow. I have a problem with addToFolder() function. I have the following piece of code that copies my new spreadsheet into a folder (test/sheets) in my Google Drive:
var ss = SpreadsheetApp.create("test");
var ssID = ss.getId();
DocsList.getFileById(ssID).addToFolder(DocsList.getFolder("test/sheets"));
My problem is that now I have 2 versions of the same file (one in the root of my Google Drive folder and the other in test/sheets folder), whenever I try to delete either of the copies, the other copy is deleted as well. Is there a way to delete the old file and keep the new one OR is there a way to create the file in the desired folder in first place?
EDIT :
thanks for you quick response. I played with this for couple of hours but still have problem copying the file to the destination folder. The problem is that even when I use makeCopy Method of the file, still addToFolder is the only option to mention the folder. Again this ends up having the tagged filename in the destination folder.
I had the same problem with the copy method.
Here is my new Code:
var SetLocationFile = "icompare/sheets/stocks"
var FolderID = DocsList.getFolder(SetLocationFile);
var FileID = DocsList.getFileById(ssID);
FileID.makeCopy("test3").addToFolder(FolderID);
Folders in Google Docs\Google Drive are actually tags. When you "add" a file to the folder "test/sheets", you do not make a copy of your file, you just attach the tag "test/sheets" to it. Now the same file is shown both in the "test/sheets" folder (i.e. in the list of all files with the tag "test/sheets") and in the root. If you wish to make a copy of the file, you should use the copy method. (Please let me know if I just misunderstand your question.)
I realize this is an old questions but you can simply use .removeFromFolder(DocsList.getRootFolder()); to remove the file from the root folder.
I would also like to know the answer to this question.. seems rather "weird" that the API does not even provide a way to create spreadsheets and place them in a certain map? And no, I do not want a Copy of the file, I want the file to be in a specific map and in no other map...