Given a file or path - I can use FileUtils (or similar) to work with files. I'd like to be able to alter the current working directory in my extension.
I see in node.js there is process.chdir(directory) but I am unable to access that object.
Is there any other way to change the current working directory.
I am trying to create a simple plugin that when you open the file dialog, the directory your file listing is the same as the currently opened file. The simple implementation being:
MainViewManager.on("currentFileChange", function (e, newFile) {
process.chdir(newFile.parentPath); // This is my FAIL
});
Brackets, like many GUI apps, doesn't use the current working directory very much once it's up and running. So there is probably a different way to accomplish what you're looking for.
When you say...
when you open the file dialog, the directory your file listing is the same as the currently opened file.
...do you mean you want the file tree on the left side of the window to change? If so, try the ProjectManager.openProject() API.
...or do you mean you want to open a file-picker dialog box (like what you see when you choose File > Open in the menu)? If so, you can use FileSystem.showOpenDialog() - the 4th argument is the directory to show when the dialog is first opened.
Related
My GPS does not display the subfolders under "src" although they exist and are non empty. When I try to create a new subfolder from within GPS, it gets created but does not show under "src". I am using (community) GPS version 20180523 on Windows 10.
I have tried the following.
(1) I fiddled around with the folder display options in the top right corner of the project tab with no success.
(2) I aggressively hit the refresh button.
(3) I created the subfolders I want in Windows explorer.
How can I get my folder-organised code to show correctly in GPS?
Thanks.
In your project properties GUI, go under Sources->Directories and check the "Include Subdirectories" checkbox. To add it manually to your GPR file, open it and add "/**" to the end of your Source_Dirs option:
for Source_Dirs use ("src/**");
I have excel importer in my application when I click on the "Upload" button I will get a pop up window with file upload screen where I can select the excel from the specified path. How to handle this in Robot Framework? Can any one help me how to handle the case?
Selenium2Library provides Choose File keyword for the same.
It takes two arguments, first is locator for the button and second is path to the file which needs to be uploaded.
e.g.
Choose File xpath=.//div/input ${TEMPDIR}${/}file_pa.csv
If you're using a dialog or input that WebDriver can interact with, then Sachin's answer about Choose File is the way to go.
If you're talking about the pre-HTML5 file-chooser dialogs provided by the browser, then Selenium2Library can't do this. However RobotFramework isn't just a wrapper around Selenium2Library so you can use something else that allows you to interact with the file upload screen.
I've done it in the past using AutoIt.
If you're not explicitly testing the upload dialog (and why should you, since it's provided as an atomic widget by your browser) then you should consider ways to simply avoid it. Perhaps a simple rest interface for uploading files.
I think this should be a relatively easy one to answer, I hope, but is proving to be a bit of a stress!
I have used an Icon on an old application developed some years ago and I would now like to use the icon for a current project.. however..
I added the icon using the upload/import icon-image in the properties window, and did not add it in the project resources file, nor specify its location anywhere in my code, using only the icon tool in the properties window.
Now wanting to find the icon image file to use again, I cannot find it anywhere! I have trawled through all the project files looking for the image file or a ref to its location, but have found nothing; except for:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
When running the application the icon is still clearly visible in the applications taskbar tile.
Does anyone know where the icon file is stored / how I can retrieve it?
Thank you in advance.
It is stored in "{Your_project_name}.{Form_name}.resources" file. Search inside the "obj" folder which is in your project folder.
Now open the command prompt of Visual Studio. We will convert this ".resources" file into a ".resx" file. We use "resgen" command here.
resgen foo.resources bar.resx
The .resx can then be added to a C# project. You can find your icon file there.
I've got an interactive presentation, and it's all working as it should.
Now I want to add a function to download the currently visible image/video.
Because this presentation has a lot of files (all stored under assets/...) and it's a pain to navigate through the assets, I want an easy way to just click a button and get a "Save as.." window.
I've managed to get the url of the media, so now I just need a way to show a "save as.." dialog to allow the users to save/download the file and save it locally.
This whole presentation should be put online, so all the files are located somewhere in the /assets/.. folder inside the project.
Any ideas of how to do this? =)
Thanks!
EDIT #1:
For now I'm using "navigateToURL" to open a new browser window with the media. This works, but is there a way to show a "Save as.." dialog instead of opening the image?
Or any other ways to do this? =)
You are looking for the FileReference class, in particular the FileReference.save( data:*,defaultFileName:String = null ) method. That will open up a "Save..." dialog to save the corresponding data object and allow you to set a default file name. I'm unsure if this class can also handle the download as I have never had a time when I needed to prompt to save something that was to be downloaded. If it cannot handle it, you'll need to look into the URLStream class. That can handle the download and either on ProgressEvent.PROGRESS or Event.COMPLETE, you simply do a URLStream.readBytes( byteArray ); to save the downloaded bytes to a ByteArray and then that is the data object you save. I would look into the FileReference class, though. Odds are it can handle downloads as well.
I need user download JPEG file from my app, however, when user change the file name the saved file will be downloaded without extension.
For Example: I am using FileReference.download() and set the default filename as "demoPic.jpg" and user's windows system setting control file extension not being shown. So when the dialog opens a download window, only "demoPic" shown as the filename. If user saved file without changing filename, the saved file will be OK. But if user change file name, the download file will be saved without extension. is it possible to add file extension to filename when user forget it by flex code?
This is a known problem with Flash Player. An enhancement request is filed with Adobe. Please visit and vote for it: https://bugs.adobe.com/jira/browse/FP-2014
It does not seem practical to train users not to rename the file. Here is the workaround I use for my app:
The problem only happens on Windows with ActiveX plugin. Detect ActiveX with Capabilities.playerType (only ~25% of users in my experience)
If ActiveX plugin, fall back to 'navigateToURL()' to bounce the file on your server. Using this function is less desirable than FileReference.download() because it is less controllable (the browser is in charge, rather than your app), but it results in a Save dialog box where the user can rename the file safely.
I have the same problem and was not able to fix it until now. It seems it is a problem with flash + windows. :( sorry to inform but I did not found any fix.
If this can be called a workaround, is somehow to warn users and ask them to place also the extension when they rename the file.
Had same problem. Used CONCAT to manually add extension. It does not appear in the dialog box when saving but DOES save as a text file with a .txt extension when viewed in Windows Explorer. Doesn't seem to work but actually does!
var final_filename:String = filename.concat(".txt");
//Create text to save from text field
var newDataFile:TextField = new TextField();
newDataFile.text=myTextField.text;
//create file reference to save file
var file:FileReference = new FileReference();
file.save(newDataFile.text, final_filename);
you just need to use navigateToUrl(ur)
var ur:URLRequest=new URLRequest();
var fr:FileReference=new FileReference();
fr.download(ur,<FILENAME>);
"download" method call fileBrowser and then call servlet .
then flex can't catch file extension
but "navigateToUrl" called servlet first then servlet call fileBrowser
then html can catch file extension