How to copy file from applicationStorageDirectory into dataDirectory? - ionic-framework

I would like to copy an image file located in www/assets/imgs/christmas.jpg to the dataDirectory folder using the Ionic Native File Plugin, however I don't know how to access the www folder. I tried the following:
this.file.checkFile(this.file.applicationStorageDirectory, 'assets/imgs/christmas.jpg')
But it always returns NOT_FOUND_ERR.

You should change applicationStorageDirectory to applicationDirectory (although I am not sure what the difference is) and add www in front of the file path as the application directory contains the www folder and not its contents. So instead of assets/imgs/christmas.jpg use www/assets/imgs/christmas.jpg

Related

How can I save a local file into assets folder in Flutter

My flutter desktop application takes a local file (audio/video/image) as user input. Now I need to save it to somewhere for later usage. So that even if the device changes the application can still access them using relative path.
What I want to do is copy this file to assets folder using file.copy method. But how can I get the assets folder's directory? I don't want to hardcode assets folder's absolute path. Is there any way to copy files into assets folder using relative path?
Or any alternate way to do the task?
assets is read-only. Use documents directory where the application can store files that only it can access.
final directory = await getApplicationDocumentsDirectory();
See Read and write files for details.

Flutter Dart File path

quick Flutter Dart issue.
I am trying to read from a text file located inside the app's directory, however Flutter does not recognize a single file path that I provide it. The file path is always responded to with "OS Error: No such file or directory, errno = 2".
I am trying to read from a file located in assets/importfiles, from a dart class inside lib/viewmodels. The assets directory has already been added to pubsec.yaml.
Here is the picture of my directory structure
I can even have the main class locate and print out the files' paths using rootBundle, but trying to initialize a new File using those paths provides the same error text.
If I were to use path provider to locate and read from files, how would I initially put the files into the Temporary Directory or Application Documents Directory, if Flutter does not recognize the file paths of the files that I want to insert?
Just You need to remove folder name ''.
assets\importfiles
to
assets Or importfiles
Thanks You.Happy To help you
Have you tried putting a "/" before "assets" in the file path?
I'm not sure that this will fix the error, let me know if it works!

How to specify path in .config file relative path to folder?

I have folder "NuGetPackages". I need to access only the folder on my computer is OK but on server is different folder structure where the project is store
what i use on my computer absolute path:
C:\workspace\HUD\02_Development\04_Tools\NuGetServer\NuGetPackages
What should I write in the config file to make sure the path is ..\NuGetPackages expanded relative to the config file rather the working?
directory?
I can't change the app I can only change the config file.
I have also try "~/NuGetPackages" but didn't work.
In short, you can't do exactly what you're trying to do.
If you can't change any of the code, your only real option is to use config transforms. You can have your *.Debug.config use your local path, and then your *.Release.config (or whatever your published build configuration is), and use the server's path.
Here are some docs on doing config transforms: https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx

ownCloud directory renamed / No such file or directory

I installed ownCloud on my webspace (I don't own a server), accessing it with a specific subdomain (i.e. http://sub.domain.com). I now had to rename the originally directory, which I did, and pointed the subdomain to the new directory. Sadly, ownCloud isn't working anymore. So I took a look at the log file:
"Unable to create file (...) No such file or directory"
So I guess ownCloud tries using the old path. Where can I change this setting?
Just solved the problem - had to change the
datadirectory
inside the ownCloudPath/config/config.php

Create a File in src directory of Eclipse plugin

I want to create a file in the current directory of eclipse plugin.
I tried to create the file using :
File file = new File("filename.txt");
But, it is not working.
EDIT: I want to create the file in the same directory as that of "src" folder
Are you trying to create empty file within the pproject dir tree? or you want to create new file programatically? If you want to create empy file, go to File>New>Empty file (or similar, I do not have eclipse installed, Im writing out of memory), and if programatically: you have written line that initializes file at given path (if file cannot be initialized (no such file, or similar) - this will throw an exeption), but does not create it. To create file you need to write second instruction, just like:
file.create();
If the location (inside your project) is correct, then simply do this (not including try catch etc):
File test = new File("test.txt");
test.createNewFile();