Is it possible to create a folder for my application, to store my application data inside that folder only?
If you want to create folder, how say Smart Developer use that code:
//Import classes to your project
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
//Name of folders
private static string MyFolder = "MyFolder";
//Folders
private StorageFolder Folder;
void async task Create_MyFolder(){
Folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(MyFolder, CreationCollisionOption.OpenIfExists);
}
I think it's good way to program in this case use this CreationCollisionOption:
CreationCollisionOption.OpenIfExists
Because you enter in your application, always delete this folder and data inside, and i think it's not a good idea... But explore the other "CreationCollisionOption", because u can interested for other option. Personally I prefer declare public folder and folder name because sure you will use in the future and it's not necessary to repeat this code all time...
Good luck, sorry for my english and tell us if you can solve your problem or if you need more information! :)
here it is sample code to do that
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
and than to create folder
StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync
("myFolder", CreationCollisionOption.ReplaceExisting);
see complete example here
Related
I have created a forge app, for revit, using the provided deleteapps design automation template, and the design automation API. The goal of this app is to process and export content from revit file.
My question is, how to get the current working directory, in the app, when a workitem starts?
public void HandleDesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e)
{
e.Succeeded = true;
Export(e.DesignAutomationData);
}
There is ModelPathUtils.ConvertUserVisiblePathToModelPath(model); but I dont want a path to a revit file, just a base path, where I can create folders.
Design Automation allows you to write to current working folder. It is a unique path for each job. You can call Directory.GetCurrentDirectory() to access the current folder.
string path = Directory.GetCurrentDirectory();
This will give you the root folder for a given job. You are allowed to create sub folders and save files within this folder.
You can also take a look at the current RVT Document PathName property. Not sure whether it lives in the current directory, though, but it might be interesting to check.
i want to use script task in ssis to send file in a specific folder after processing how can i do it ?
Thank u
Moving the file shouldn't be a problem. Take a look at this. You can pass in the path of files as variables.
using System.IO;
string path = (string)Dts.Variables["User::path1"].Value;;
string path2 = (string)Dts.Variables["User::path2"].Value;;
try
{
// Ensure that the target does not exist.
if (File.Exists(path2))
File.Delete(path2);
// Move the file.
File.Move(path, path2);
}
Using ActionScript 3 I want to access multiple text files from a subfolder within my assets folder: project/src/assets/myFiles/
I know how to embed and read one specific text file if I know the exact file name:
[Embed(source="assets/myFiles/file1", mimeType="application/octet-stream")]
private static const FILE1:Class;
private function read():void {
var text:String = (new FILE1() as ByteArray).toString();
}
Since I have multiple files in the folder myFiles I'd like to read all of them.
I don't know the exact number and names of these files at compile time.
Is it possible to access them by retreiving an array of objects? Or is it possible to list all the file names read them otherwise?
Since I don't know the names at compile time I don't know how to embed and access those files.
Example of my files:
project/src/assets/myFiles/file1
project/src/assets/myFiles/file2
project/src/assets/myFiles/anotherFile
Edit: I am using AIR.
Edit: I am using Flex.
Edit: Current approach is to not use the asset directory but a dedicated (further) directory. I include this folder in the package so it and its content is automatically created in the application directory on compililation / installation. I read this folder via FileStream as suggested within the comments by Organis.
I'm creating a generator with yeoman and I have a small issue.
Basically my generator will be abble to create a module structure like that :
nameofmodule
classes
controllers
nameofmodule.php
When I execute my generator I'm in the parent folder of nameofmodule (nameofmodule folder is created by the generator).
Now I would like to save a yo-rc.json file to save some configurations (as the module name).
The issue is that I would like the yo-rc.json file to be in the nameofmodule folder and not in the folder where I've initiated the yeoman generator.
Do you know how I could change the yo-rc.json file path ? Or maybe create a new one in nameofmodule ?
Thanks a lot
I managed to change .yo-rc.json path by changing destination root path:
this.destinationRoot(path.join(this.destinationRoot(), '/' + this.appDir));
So after I created my app structure I called:
this.on('end', function () {
this.destinationRoot(path.join(this.destinationRoot(), '/' + this.appDir));
this.config.set('appName', this.appName);
this.config.set('appDir', this.appDir);
this.config.set('modules', []);
});
Right now it works for me only with Base generator. I have no idea how to apply destination root across NamedBase generators.
I hope this is helpful.
I'm using an ActionScript Library project to share code and assets / resources between a Mobile and a Desktop ActionScript projects.
The library project has been added to the two other projects via the 'Add Project' option on the 'Library Path' tab, with the linkage type 'Merged into Code', and all the classes within it can be accessed by the other projects, and work properly.
However it contains a SQLite database file, which I want to copy out to the File.applicationStorageDirectory on the target system on the first load of the app, and I'm not sure how to get a reference to the file within the library project to copy it out.
The location of the db file is: LibraryProj - src/database/dbFile.db and I thought using File.applicationDirectory and then a path 'into' the swf would give me access to it, but none of the following tests say the file exists.
var test:File;
test = File.applicationDirectory.resolvePath("app:/src/database/dbFileDb.db");
trace("test.exists==" + test.exists);
test = File.applicationDirectory.resolvePath("src/database/dbFileDb.db");
trace("test.exists==" + test.exists);
test = File.applicationDirectory.resolvePath("database/dbFileDb.db");
trace("test.exists==" + test.exists);
test = File.applicationDirectory.resolvePath("dbFileDb.db");
trace("test.exists==" + test.exists);
Is this the correct method to copy resource / asset files out of a swf containing merged libraries and onto the app's storage directory? Is it even possible to share resources / assets from Library projects in this way?
Any advice would be very much appreciated.
After doing some more research about using the [Embed] tag in AS3, I've now worked out that this is what I should have been using to make the file available to consuming projects (I'd previously only used it for images, and didn't think of it for other file types too).
[Embed('igniteDb.db', mimeType="application/octet-stream")]
public static const myReferenceDbFile:Class;
To copy the file to the File.applicationStorageDirectory i'm using the following code. It converts the embedded file to a byte array, and then writes this out via a FileStream class to the destination file.
//write the embedded database file data into app user files directory
var bundleDbBytes:ByteArray;
bundleDbBytes = new myReferenceDbFile();//gets a reference to the embedded db file
var outputDbFile:File = File.applicationStorageDirectory.resolvePath(DB_FILE_NAME);
var fileStream:FileStream = new FileStream();
fileStream.open(outputDbFile, FileMode.UPDATE);
fileStream.writeBytes(bundleDbBytes);
fileStream.close();
And hey presto, the database is ready to use.