Programmatically open a file and save it in a new directory
To start off, I'm relatively new to LabVIEW and did a couple searched about this and couldn't find anything pertaining to what I wanted.
Right now I have an event structure where I click a button and the file dialog comes up. I then select a CAN database file.
After that is done I'd like to save the file to the program's directory and save the relative path to an array/spreadsheet/whatever (I haven't decided what would be the most appropriate yet). Saving the relative path is the easy part. After opening the file, I can't seem to find anything that will let me programmatically save it to another location.
Does anyone know how to do this? Thank you for the help.
Thanks for the help. Apparently, I didn't look aroun good enough or missed it.
Similar Messages
-
In C#, how can I detect an opened PDF file and save it into disk?
he WebBrowse componente in C# opened an PDF file inside. The file came from the Internet. So, the Adobe Acrobat Reader was called and opened the file correctly. I want to save this file to disk. How can I do it?
The WebBRowse component does not have access to the PDF content.PDFs are not designed to be editable. Your engineers can make comments using Adobe Reader without any extra steps provided they use the highlight and sticky note comments. If you want them to have access to the full range of comment markup you will need to use Acrobat to apply extended rights to the file.
-
Close ALL open files and save jpg with jpg option
Hi,
I have some (a lot) of -jpg images to crop, and resize, while I have to do this one by one based on what portion of the image to crop, once done I need to close, and save them.
To speed up the process I open several files, and do the crop&resize, and when finished I use "close all", and would like to avoid to confirm the "save" dialogue, and the "jpeg options" "image quality option" dialogue, having to say save, and the option set to a given value.
Unfortunatelly I am not a coder, and didn't understand anything from the Javascript Scripting Reference guide.
I found this
app.docRef.close(SaveOptions.SAVECHANGES);
here, I pasted it into ExtendScript, saved it, but when opening the script from file > scripts > browse it returns error 21 (undefined is not an object)
Will you please kindly give me the script?
Thank youAdd this snippet to a script file.
Load script file in PS scripts folder
Restart photoshop
Assign keyboard shortcut to script
#target photoshop
//Make Photoshop the formost Appplication
app.bringToFront();
// Requires at least one open document
while (app.documents.length > 0)
//Save all open windows
{activeDocument.close(SaveOptions.SAVECHANGES);} -
I have a five year old version of imovie that generally works fine. However, when I add a photo using the 'Ken Burns' effect then save the movie, the next time I open the file and click 'show photo settings' the picture appears black and I cannot change the zoom. Any suggestions?
Have you rendered both iOS 7 and iOS 8 (both of which will work on your iPhone 5) out of the question entirely without trying every possible configuration? The animations can be disabled entirely, if that's the problem. And if the whiter-brighter user interface is the problem, there's reverse-contrast modes that darken everything. You can expose accessibility controls to gain immediate access to these functions to toggle them on and off. I guess my point is you may have decided against upgrading the OS based on an early experience with iOS 7 when Apple has since made changes in later revisions to address some of the usability complaints.
Now, Apple's instructions for downloading older versions of apps is to do so from the Purchased list, not from the app's product page.
See here:
Install the latest compatible version of an app on an earlier version of iOS or OS X - Apple Support
Let us know how that works for you. -
Read multiple files and save all into one output file(AGAIN)
Hi, guys
I need your help for reading data from multiple files and save the results into one output file. When files are selected from file chooser, my program read the data line by line , do some calculations and save the result into the output. I made an array to store input files and it seems to be working fine, but when it comes to SaveFile() function, issues NullPointException message.
public class FileReduction1 extends JFrame implements ActionListener
// GUI definition and layout
/* ACTION PERFORMED */
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().equals("Open File")) getFileName();
/* OPEN THE FILE */
private void getFileName() {
// Display file dialog so user can select file to open
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(true);
int result = fileChooser.showOpenDialog(this);
// If cancel button selected return
if (result == JFileChooser.CANCEL_OPTION) return;
if (result == JFileChooser.APPROVE_OPTION)
files = fileChooser.getSelectedFiles();
textArea.setText("");
if(files.length>0)
filelist="";
System.out.println("files length"+files.length);
for(int i=0;i<files.length;i++)
System.out.println(files.getName());
filelist+=files[i].getName()+" ,";
if (checkFileName(files[i]) )
openButton.setEnabled(true);
readButton.setEnabled(true);
textArea.append("file "+files[i].getName()+"is a proper file"+"\n");
readFile(files[i]);
textfield.setText(filelist);
else{JOptionPane.showMessageDialog(this,"Please select file(s)",
"Error 5: ",JOptionPane.ERROR_MESSAGE); }
// Obtain selected file
/* READ FILE */
private void readFile(File fileName_in) {
// Disable read button
readButton.setEnabled(false);
// Dimension data structure
getNumberOfLines(fileName_in);
data = new String[numLines][4];
// Read file
readTheFile(fileName_in);
// Rnable open button
openButton.setEnabled(true);
/* GET NUMBER OF LINES */
/* Get number of lines in file and prepare data structure. */
private void getNumberOfLines(File fileName_in) {
int counter = 0;
// Open the file
openFile(fileName_in);
// Loop through file incrementing counter
try {
String line = fileInput.readLine();
while (line != null) {
counter++;
System.out.println("(" + counter + ") " + line);
line = fileInput.readLine();
numLines = counter;
closeFile(fileName_in);
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File",
"Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile(fileName_in);
System.exit(1);
/* READ FILE */
private void readTheFile(File fileName_in)
// Open the file
//int row=0;
int col=0;
openFile(fileName_in);
System.out.println("Read the file");
// Loop through file incrementing counter
try
String line = fileInput.readLine();
while (line != null)
boolean containsDoubles = false;
double temp;
String[] lineParts = line.split("\t");
try
for (col=0;col<lineParts.length;col++)
temp=Double.parseDouble(lineParts[col]);
data[row][col] = lineParts[col];
containsDoubles = true;
System.out.print("data["+row+"]["+col+"]="+lineParts[col]+" ");
} catch (Exception e) {row=0; col=0; temp=0.0;}
if (containsDoubles){ row++;}
System.out.println();
line = fileInput.readLine();
catch(IOException ioException)
JOptionPane.showMessageDialog(this,"Error reading File", "Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile(fileName_in);
System.exit(1);
//System.out.println("length"+data.length);
closeFile(fileName_in);
process(fileName_in);
/* CHECK FILE NAME */
/* Return flase if selected file is a directory, access is denied or is
not a file name. */
private boolean checkFileName(File fileName_in) {
if (fileName_in.exists()) {
if (fileName_in.canRead()) {
if (fileName_in.isFile()) return(true);
else JOptionPane.showMessageDialog(null,
"ERROR 3: File is a directory");
else JOptionPane.showMessageDialog(null,
"ERROR 2: Access denied");
else JOptionPane.showMessageDialog(null,
"ERROR 1: No such file!");
// Return
return(false);
/* OPEN FILE */
private void openFile(File fileName_in) {
try {
// Open file
FileReader file = new FileReader(fileName_in);
fileInput = new BufferedReader(file);
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
textArea.append("OPEN FILE\n---------\n");
textArea.append(fileName_in.getPath());
textArea.append("\n");
//System.out.println("File opened successfully");
/* CLOSE FILE */
private void closeFile(File fileName_in) {
if (fileInput != null) {
try {
fileInput.close();
catch (IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
System.out.println("File closed");
private void process(File fileName_in) {
//getNumberOfLines();
//data = new String[numLines][3];
// Read file
double temp,temp1;
//readTheFile();
//System.out.println("row:"+row);
//int number=data.length;
//System.out.println(number);
for (int i=0; i<row; i++)
temp=Double.parseDouble(data[i][1]);
sumx+=temp;
temp1=Double.parseDouble(data[i][3]);
sumy+=temp1;
multixy+=(temp*temp1);
square_x_sum+=(temp*temp);
square_y_sum+=(temp1*temp1);
//System.out.println("Sum(x)="+sumx);
double tempup=(row*multixy)-(sumx*sumy);
double tempdown=(row*square_x_sum)-(sumx*sumx);
slope=tempup/tempdown;
double tempbup=sumy-(slope*sumx);
intb=tempbup/row;
double tempside=(row*square_y_sum)-(sumy*sumy);
double cordown=Math.sqrt(tempdown*tempside);
corr=tempup/cordown;
r_sqrt=corr*corr;
textArea.append("Data for file"+ fileName_in.getName()+" have been processed successfully.");
textArea.append("\n");
textArea.append("Please enter output file name including extension.");
System.out.println("number"+row);
System.out.println("slope(m)="+slope);
System.out.println("intecept b="+intb);
System.out.println("correlation="+corr);
System.out.println("correlation="+r_sqrt);
saveFile();
private void saveFile()
textArea.append("SAVE FILE\n---------\n");
if (openFile1())
try {
outputToFile();
catch (IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Writing to File",
"Error",JOptionPane.ERROR_MESSAGE);
private boolean openFile1 ()
// search for the file path
StringBuffer stringpath;
title=textfield1.getText().trim();
int temp=fileName_in.getName().length();
int temp_path=fileName_in.getPath().length();
int startd=(temp_path-temp);
stringpath=new StringBuffer(fileName_in.getPath());
stringpath.delete(startd, temp_path+1);
//System.out.println("file-path="+temp_path);
//System.out.println("length-file="+temp);
path=stringpath.toString();
fileName_out = new File(path, title);
//System.out.println(file_out.getName());
if (fileName_out==null || fileName_out.getName().equals(""))
JOptionPane.showMessageDialog(this,"Invalid File name",
"Invalid File name",JOptionPane.ERROR_MESSAGE);
return(false);
else
try
boolean created = fileName_out.createNewFile();
if(created)
fileOutput = new PrintWriter(new FileWriter(fileName_out));
fileOutput.println("File Name"+"\t"+"Slope(m)"+"\t"+"y-intercept(b)"+"\t"+"Coefficient(r)"+"\t"+"Correlation(R-Squared)");
return(true);
else
fileOutput = new PrintWriter(new FileWriter(fileName_out,true));
return(true);
catch (IOException exc)
JOptionPane.showMessageDialog(this,"Please enter the file name","Error",JOptionPane.ERROR_MESSAGE);
return(false);
private void outputToFile() throws IOException
// Initial output
textArea.append("File name = " + fileName_out + "\n");
// Test if data exists
if (data != null)
fileOutput.println(fileName_in.getName() +"\t"+ slope+"\t"+intb+"\t"+corr+"\t"+r_sqrt);
textArea.append("File output complete\n\n");
else
textArea.append("No data\n\n");
// End by closing file
initialcomp();
fileOutput.close();
private void initialcomp()
slope=0.0;
intb=0.0;
corr=0.0;
r_sqrt=0.0;
sumx=0.0; sumy=0.0; multixy=0.0; square_x_sum=0.0; square_y_sum=0.0;
for(int i=0;i<data.length;i++)
for(int j=0;j<data[i].length;j++)
data[i][j]=null;
/* MAIN METHOD */
public static void main(String[] args) throws IOException
// Create instance of class FileChooser
FileReduction1 newFile = new FileReduction1("File Reduction Program");
// Make window vissible
newFile.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
newFile.setSize(500,400);
newFile.setVisible(true);
Sorry about the long lines.
As you can see, all input files saved in array called files, however when OpenFile1() function is called, it take input (fileName_in) as a single file not an array. I'm assuming this causes the exception.
When there's muptiple inputs, program should take each file from getFileName() to outputToFile() sequentially.
Does anybody have an idea to solve this?
Thanks a lot!!you naming convention is confussing. you should follows Java naming convention..you have a getXXX but decalred the return type as "void"...get usully means to return something...
your code is doing too much..and hard to follows..
1. get the selected files
for each selected file
process the file and return the result
write out the result.
/** close the precious resource */
public void closeResource(Reader in){
if (in != null){
try{ in.close(); }
catch (Exception e){}
/** get the total number of line in a file */
public int getLineCount(File file) throws IOException{
BufferedReader in = null;
int lineCount = 0;
try{
in = new BufferedReader(new FileReader(file));
while ((in.readLine() != null)
lineCount++;
return lineCount;
finally{ closeResource (in); }
/** read the file */
public void processFile(File inFile, File outFile) throws IOException{
BufferedReader in = null;
StringBuffer result = new StringBuffer();
try{
in = new BufferedReader(new FileReader(inFile));
String line = null;
while ((in.readLine() != null){
.. do something with the line
result.append(....);
writeToFile(outFile, result.toString());
finally{ closeResource (in); }
public void writeToFile(File outFile, String result) throws IOException{
PrintWriter out = null;
try{
out = new PrintWriter(new FileWriter(outFile, true)); // true for appending to the end of the file
out.println(result);
finally{ if (out != null){ try{ out.close(); } catch (Exception e){} } }
} -
Can not open JPEG files and can not create JPEG files from other software
Can not open JPEG files and can not create JPEG files from other software (For example from Solidworks).
When I try to right click on a JPEG, a notice window appears written: "Windows Explorer has stopped working - Windows is
checking for a solution to the problem" and then the notice box disapears, the desktop appears and I can continue working.
From the other side - If I try to save as JPEG a screen of Solidworks (like a view of a part) the Solidworks falls but the JPEG
is created (I can see its name in the directory I created it).
I can open the JPEGS with the Paint software if I want but not with the Windows Photo Viewer.
I have the feeling that the Windows Photo Viewer disapeared from my computer - just a feeling.
I will appreciate your assistance.
Avi T. 2014Hi,
Did Windows Photo Viewer option appear when you right click the JPEG file and select open with?
I would like suggest you use Clean Boot to troubleshoot if there is third-party software conflict:
How to perform a clean boot in Windows
http://support.microsoft.com/kb/929135
Karen Hu
TechNet Community Support -
Adobe Photoshop CC shuts down when trying to open a file or save it!
Adobe Photoshop CC shuts down when trying to open a file or save it. I'm running windows 7 professional and have tried unistalling/reinstalling preferences but does not work. I will list the events logs for help in seeing what I need to do to make this work. Please help!
This is the first of 2 errors listed associated with photoshop cc.
Log Name: Application
Source: .NET Runtime
Date: 10/12/2014 9:52:29 AM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Owner-PC
Description:
Application: Photoshop.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException
Stack:
at P1.WICCODEC.CODEC.ImageCoreBasedDecoder..ctor(System.Runtime.InteropServices.ComTypes.ISt ream, System.String)
at P1.WICCODEC.CODEC.WICBitmapDecoder.CreateICDecoder(System.Runtime.InteropServices.ComType s.IStream)
at P1.WICCODEC.CODEC.WICBitmapDecoder.QueryCapability(System.Runtime.InteropServices.ComType s.IStream, UInt32 ByRef)
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2014-10-12T14:52:29.000000000Z" />
<EventRecordID>62867</EventRecordID>
<Channel>Application</Channel>
<Computer>Owner-PC</Computer>
<Security />
</System>
<EventData>
<Data>Application: Photoshop.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException
Stack:
at P1.WICCODEC.CODEC.ImageCoreBasedDecoder..ctor(System.Runtime.InteropServices.ComTypes.ISt ream, System.String)
at P1.WICCODEC.CODEC.WICBitmapDecoder.CreateICDecoder(System.Runtime.InteropServices.ComType s.IStream)
at P1.WICCODEC.CODEC.WICBitmapDecoder.QueryCapability(System.Runtime.InteropServices.ComType s.IStream, UInt32 ByRef)
</Data>
</EventData>
</Event>
Second Error
Log Name: Application
Source: Application Error
Date: 10/12/2014 9:52:30 AM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: Owner-PC
Description:
Faulting application name: Photoshop.exe, version: 14.2.1.570, time stamp: 0x52f4a1d7
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x531599f6
Exception code: 0xe0434352
Fault offset: 0x0000812f
Faulting process id: 0x16c8
Faulting application start time: 0x01cfe62c123b9d8e
Faulting application path: C:\Program Files\Adobe\Adobe Photoshop CC\Photoshop.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 633cd65f-521f-11e4-a63f-001cc0725d07
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2014-10-12T14:52:30.000000000Z" />
<EventRecordID>62868</EventRecordID>
<Channel>Application</Channel>
<Computer>Owner-PC</Computer>
<Security />
</System>
<EventData>
<Data>Photoshop.exe</Data>
<Data>14.2.1.570</Data>
<Data>52f4a1d7</Data>
<Data>KERNELBASE.dll</Data>
<Data>6.1.7601.18409</Data>
<Data>531599f6</Data>
<Data>e0434352</Data>
<Data>0000812f</Data>
<Data>16c8</Data>
<Data>01cfe62c123b9d8e</Data>
<Data>C:\Program Files\Adobe\Adobe Photoshop CC\Photoshop.exe</Data>
<Data>C:\Windows\system32\KERNELBASE.dll</Data>
<Data>633cd65f-521f-11e4-a63f-001cc0725d07</Data>
</EventData>
</Event>The first error has nothing to do with Photoshop - that's some .NET application.
The second error is most likely connected to a third party plugin or driver.
And you're running Photoshop CC (14.x) instead of the current Photoshop CC 2014 (15.x). -
What Steps do I take to edit raw files and save for web use, such as Instagram, Facebook, Websites, and emailing?
When you open a raw file it will open in Adobe camera raw. That is where you can do most of the editing. Then it will be placed inside Photoshop where you can do more if needed.
Now you can use the save for web dialog to export your image as a png or jpg to use on those sites. -
How to tell script colse all files and save, but no untitle docs
Hi everyone
I want to colse the open files and save them but no those files which have never been saved.
I try this script but after ran, all the files are no be saved.
var docs = app.documents;
for (var i = docs.length-1; i >= 0; i--) {
if(app.activeDocument.saved == false){
docs[i].close(SaveOptions.NO);
else if(docs[i].close(SaveOptions.YES));
can someone tell me what's wrong with the script?
thanks
Regard
Teetanvar docs = app.documents;
for (var i = docs.length-1; i >= 0; i--) {
if (docs[i].saved == false) {
docs[i].close(SaveOptions.NO);
else {
docs[i].close(SaveOptions.YES); -
System exec, How I say to open one file and make operation in external program?
Hi,
I got called an external program with the system exec.vi, but i would like the program open the file saved in the other window, i can get the file path, but how Can I put the file path in the external program and the program open the file and I tell (in this case compile), since i open one file code c and only i must to open and say to the program 'compile' and then close external program.
Any help?. Thanks.
Attachments:
system_exec.GIF 8 KBHi Fonsi,
System Exec.vi will allow you to run commands like launching a program easily but it is difficult and many times not possible to execute commands within an application.
A better way maybe to approach this though ActiveX. Please look at the following example that uses ActiveX to communicate with Excel.
Writing Rows to Excel 97 and Excel 2000 Using ActiveX
If you are not familiar to ActiveX and LabVIEW, please read the document below:
ActiveX and LabVIEW
I hope this
helps.
Sincerely,
Feroz
National Instruments -
Because I can no longer open Adobe files, and have tried all obvious solutions, I've been told to defrag the Intel portion of my MacBook Pro. How do I do this?
I never use the Intel side, and have never partitioned the MacBook Pro.
Message was edited by: MacGirl221bI never use the Intel side,
Not understood, Intel make the processor that runs your Mac, there is no other 'side' to your Mac.
What Adobe application are you trying to open files with? -
I am trying to open my files and get a message saying that the file is invalid. The index xml file is missong
Tell us the whole Story in detail about what App (if any), version, any changes you have made recently and Importantly, the exact message - verbatim - a screenshot of the entire display would be very helpful - ÇÇÇ
-
Which Version of Adobe do I need to be able to "extract" a page from a existing file and save/download to another file?
Acrobat Pro or Standard.
-
How to use cfdocument create a PDF file and save the file in server?
Hi,
I want to use cfdocument to create a PDF file and save it in
the server for other people to download,can you give me a idea how
to do this.Thanks.
<cfdocument format = "PDF" pagetype="A4"
orientation="portrait">
</cfdocument>
MarkHi
<cfdocument filename="" format = "PDF" pagetype="A4"
orientation="portrait">
</cfdocument>
Give the physical path to the filename. You have write
permission for this folder to create a PDF file. -
I want to open a file and have it fill the desktop - how??
I have recently moved over from CS2 on PC to CS3 in MAC - I used to be able to open a file and it would open up in a full window filling the whole screen - now it opens up in a box with no surrounding space. When I maximize the minute I tap cmd + the widow reduces to minimize and just zooms into a part of the file. I am sure this is basic stuff but any help out there please??
gratefully
AngusThat's the difference between Macs and Windows. Windows opens applications in a... Window.
Try hitting the F key and see if that works for you.
Maybe you are looking for
-
Can I use multiple swfs in iOS app?
Hello everybody, I have to create an app for iOS from an existing Flash project. On the stage of the main flash multiple swfs are loaded dynamically . Is it possible to compile, in addition to the main file, all the other swfs too? If I load the swf
-
Lightroom SWF in a dreamweaver page
I created a photo gallery in lightroom and have uploaded it to my site, in a subfolder under photos. It does work with I open the html page lightroom created for it. Now I want to insert the swf file into a page on the root directory but want to ke
-
Hello, I had an older mac and it broke so I have been using windows for a little while and I really need a mac again because I am a mac user and have a lot of programs/apps, same thing that I need to use in OS X. I plan to get a mac mini because of m
-
Revision: 12994 Revision: 12994 Author: [email protected] Date: 2009-12-16 06:44:45 -0800 (Wed, 16 Dec 2009) Log Message: Fixes for two issues that were showing up in FB. QE notes: Doc notes: Bugs: SDK-24669, SDK-24686 Reviewer: Corey Cycloner:
-
Screen Distortion (Horizontal lines) Across Display
For quite some time now my Macbook display has had horizontal lines along the right side of it. These lines go from the very top to the bottom and are about an inch or two in width. Sometimes goes away when i have a Pages document open. But is consta