I have trouble getting it to copy file from src to destination.
var asMsg_path:String = fileRef.nativePath;
var origFileLoc:File = File.applicationDirectory.resolvePath(asMsg_path);
var newFileLoc:File = File.applicationDirectory.resolvePath("/java/"+asMsg);
launch an AIR app in debug mode. I need to copy a file from asMsg to the Java folder in the same location as the app.
origFileLoc.moveTo(newLocation:FileReference, overwrite:Boolean);
Related
Can I map an arbitrary directory as a subdirectory of wwwroot? That is, the directory is not under wwwroot in the file system, but within my app, it is treated like so.
For example, I have created an ASP.NET 6.0 Blzor Server project. The programme dll path is in /app/proj1/BlazorApp1.dll. If there is an image at /app/proj1/wwwroot/images/dog.jpg, it can be rendered using <img src="images/dog.jpg"/> in my page. But what if I do not want to have this images directory actually under the wwwroot directory on the file system? Can the directory be somewhere else like /data/images, and I map that path to wwwroot/images, so that /data/images/dog.jpg can be rendered with <img src="images/dog.jpg"/> within my app?
There are 3 ways to do this that i know of, Firstly adjusting the settings, which is clearly documented on msdn, under the 'Serve files outside of web root' header;
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "MyStaticFiles")),
RequestPath = "/StaticFiles"
});
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-6.0#serve-files-outside-of-web-root
For your case, since you want both wwwroot and another file, see 'Serve files from multiple locations';
var webRootProvider = new PhysicalFileProvider(builder.Environment.WebRootPath);
var newPathProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "MyStaticFiles"));
var compositeProvider = new CompositeFileProvider(webRootProvider,
newPathProvider);
// Update the default provider.
app.Environment.WebRootFileProvider = compositeProvider;
app.UseStaticFiles();
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-6.0#serve-files-from-multiple-locations
Another way would be to use MSBuild to copy the files from another directory into the wwwroot folder, see for example the following SO;
Copy files to output directory using csproj dotnetcore
Lastly, and this is not as portable, you could use symlinks, see:
A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target.
Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.
https://learn.microsoft.com/en-us/windows/win32/fileio/symbolic-links
https://en.wikipedia.org/wiki/Symbolic_link
https://superuser.com/questions/1020821/how-can-i-create-a-symbolic-link-on-windows-10
The first one should satisfy your needs.
You could try as below to update the default provider with a composite fileprovider :
var webRootProvider = new PhysicalFileProvider(builder.Environment.WebRootPath);
var newPathProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "data"));
var compositeProvider = new CompositeFileProvider(webRootProvider,
newPathProvider);
app.Environment.WebRootFileProvider = compositeProvider;
app.UseStaticFiles();
Result:
I'm running meteor on a codeanywhere container.
I want to read a file with fs (I have another container with node+express and I can use it fine there). The file is located next to the main.js script in the server folder.
In the main.js I'm trying to do this:
console.log(process.cwd());
console.log(path.resolve(__dirname));
let filePath = path.join(__dirname,"History.txt")
console.log(filePath);
let value = fs.readFileSync(filePath, 'utf8');
I've tried the simple History.txt, ./History.txt, to run it with the full result of process.cwd, from the public folder... but all I get is:
Error: ENOENT: no such file or directory, open '/server/History.txt'
process.cwd is:
/home/cabox/workspace/anaplus/.meteor/local/build/programs/server
__dirnam is:
/server
I cannot see what's wrong here
Put it in a top-level folder named private then it will be available under .meteor/local/build/programs/server/assets/app and you can then also obtain it using Assets: https://docs.meteor.com/api/assets.html
I have developed a javafx application that reads the database configuration properties from a ".properties file".When i run the app in eclipse everything works fine.The problem is when running the app from the generated executable jar,it throws me a NullPointerException because it cant read the ".properties file".
The code is :
FileInputStream fis=new FileInputStream("resources/META-INF/db/db.properties");
Properties properties = new Properties();
properties.load(fis);
I searched about this and i saw some examples of using InputStream :
Properties pp = new Properties();
InputStream is = getClass().getClassLoader().getResourceAsStream("errors.properties");
pp.load(is);
But still doesnt work.Any idea?strong text
Try creating a folder that you always have with you Jar. The folder name should be resources. This folder should have a folder named META-INF. META-INF should have a folder named db. Finally, db should have the db.properties file in it.
I know how to copy a file in sftp server. But, how to put files in a sftp folder to a suitescript array? Also, is it possible to move or delete a file in sftp server using suite script 2.0? If yes, how to do it?
The following coding is for copying a file in sftp:
var myPwdGuid = "B34672495064525E5D65032D63B52301";
var myHostKey = "AAA1234567890Q=";
var connection = sftp.createConnection({
username: 'myuser',
passwordGuid: myPwdGuid,
url: 'host.somewhere.com',
directory: 'myuser/wheres/my/file',
hostKey: myHostKey
});
var downloadedFile = connection.download({
directory: 'relative/path/to/file',
filename: 'downloadMe.js'
});
connection.upload({
directory: 'relative/path/to/remote/dir',
filename: 'copy_of_downloadme.js',
file: downloadedFile,
replaceExisting: true
});
Indeed, the SFTP module in its current version does not include a way to list the contents of a remote directory. In some scenarios the file name is known or predictable. For the other scenarios one can use a file with a known name to store the names of the other files or middleware to retrieve the list of files. Ask me if you want to know about an existing middleware solution.
I can access and play file named "Song.mp3" located in the root directory of my project but when I put it into "assets" directory I got error.
Here is my project directory:
- Test
-- src
--- Homeview.mxml
-- assets
--- Song.mp3
-- Song.mp3
I can access and play Song.mp3 located in the root folder but I get error when I want to play assets/Song.mp3.
This works:
var req:URLRequest = new URLRequest('../Song.mp3');
This does not:
var req:URLRequest = new URLRequest('../assets/Song.mp3');
I get following Runtime error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: app:/assets/Song.mp3
I think that Song.mp3 in the root directory get exported in the final swf file but assets/Song.mp3 does not. If that is the case is there a way to force Flex to export assets/Song.mp3?
You can use file class i.e. File.applicationStorageDirectory.resolvepath("your url")
or File.applicationDirectory.resolvepath("your url").Store it in File type variable;use the file.url or file.nativePath to access the file.
This will be able to retrieve your external file which is there in the applicaton folder.