How to save file to specific directory
See original GitHub issueMoving over from https://github.com/electron/electron/issues/7065 /cc @disc9562
-
Electron version: 1.3.4
-
Operating system: Windows 8.1 I am using spectron to test my app. I am opening dialog in my app like this:
ipc.on('open-directory-dialog', (event, arg) => { let returnValue = function(directory) { if (typeof directory !== 'string') { directory = directory[0] } event.returnValue = directory } let options = { properties: [ 'openDirectory' ] } if (process.platform !== 'darwin') { dialog.showOpenDialog(options, (directory) => { if (directory) { returnValue(directory) } }) return } returnValue(dialog.showOpenDialog(BrowserWindow.fromWebContents(event.sender), options))
And I want to auto select directory in test. I am using preload to do that. But it will make my app crash.
//preload
if (process.env.RUNNING_IN_SPECTRON) {
dialog.showOpenDialog = (opts, cb) => {
if (opts.title === 'open-directory-dialog') {
cb(['C:/Users/user/Desktop/']);
}
};
}
Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to save file/s to a specific directory? - Help
Hi! I have this task where I need to save file/s to a specific folder. Unfortunately, the path where I need to save...
Read more >HOW TO SAVE FILES IN FOLDERS
If you right click on the file then on Save as you can tell it where to save it. You should have a...
Read more >How to Save a Directory List in DOS
To get the complete directory tree with subdirectories and files, type dir /s, then press Enter. You will see the contents of the...
Read more >Is there a way to save a file to a specific folder inside your ...
Just pass the desired file path to the file argument. write.csv(data, file='output/data.csv'). 2 Likes.
Read more >How to save a file to a specific directory in python?
As long as you have access to the directory you can simply change your file_name.pdf' to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It isn’t the
const
that makes it work. The old code was trying to callundefined
as a function and all sorts of other dodgy things.This is just correct code 👍
Closing this out as the original question / issue has been resolved 👍
@disc9562 I have a PoC for adding
electron-test-utils
bindings to Spectron, but until that I’ll just fix your mocking function 👍