From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 6 when using Write PNG File.vi

Solved!
Go to solution

I can't understand why I'm getting this error (Generic File I/O Error). I don't believe there's anything wrong with the path I specify - but I'm clearly missing something. Running with probes shows that my image data appears to be correct, and the path looks fine to me - but I always fail with error 6.

 

Path (copied from Probe Display): "C:\Users\James.Veale\Desktop\temp\20190327 111225 \Chip 14"

Image Data: {image type =>0, image depth =>24, image => [187,197 .... and so on (the image looks fine in the Probe Display) I'm aware that this should have nothing to do with error 6.

 

I've tried using Write JPEG File.vi instead, and get Error 1, which more specifically suggests that my path is bad. Furthermore, obviously no issues if I leave the path unwired and choose from the dialog.

 

Any help understanding what's wrong with my path would be greatly appreciated.

0 Kudos
Message 1 of 20
(3,559 Views)
Solution
Accepted by topic author jrveale

You have a space before the last backslash in your file path string.  Is that actually there?

 

I believe Windows would have issues with files and folder names that end in a space.

 

Make sure your actual directory structure is clean in Windows, and that the file path doesn't have that extra space in it and try again.

Message 2 of 20
(3,549 Views)

Thanks very much. That appears to have been it!

 

I'd actually considered this but wrote it off, seeing as there weren't any problems with LabVIEW creating that folder just before trying to create the PNG file.I figured if there would be a problem using a folder ending in space, I should have already had issues creating it!

 

Thanks again.

0 Kudos
Message 3 of 20
(3,543 Views)

Did you actually create a folder with a space?  Or did you try to create a folder with a space within LabVIEW based on a string that ended in a space, and LabVIEW, or actually the operating system proceed to create it without the space?

0 Kudos
Message 4 of 20
(3,536 Views)

Good spot, I hadn't noticed that LabVIEW or Windows had automatically removed the trailing space on the folder.

 

Time for me to add a bit more path sanitation!

0 Kudos
Message 5 of 20
(3,533 Views)

A related issue.

 

Everything now works when I run the program from within the LabVIEW development environment, however I just noticed that  when I run the program from a built executable I get Error 1 at the same location.

 

None of the paths used are relative, so this shouldn't be an issue - and I don't use the Current VI's Path Constant anywhere that I'm aware of.

 

Path used: "C:\Users\James.Veale\Desktop\temp\20190327 143515\Chip 0.png" (Obtained by debug print of path to string).

 

Any ideas?

0 Kudos
Message 6 of 20
(3,507 Views)

This question was originally posted as a followup within another, but I think it's more likely to be considered a separate issue.

 

When running my program which uses Write PNG File.vi in the LabVIEW development environment, everything works well. However, when I run it from the built executable, I get Error 1 from Write PNG File.vi.

 

My paths are not relative, and I do not use the "Current VI's Path" Constant anywhere in my program, so I can't see how the location of my program could be causing the fault.

 

I've also tried running the executable as an Administrator, which appeared to have some success on first try, but successive attempts all result in the same Error 1 from Write PNG File.vi.

 

The path given to Write PNG File.vi is as follows: "C:\Users\James.Veale\Desktop\temp\20190328 091241\Chip 0.png" (obtained from debug logging of path to file) - and the executable is running in a folder on the same Desktop. I don't see any obvious issues here.

 

Can anyone help with any suggestions?

0 Kudos
Message 7 of 20
(3,432 Views)

Hi jr,

 

does that path exist?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 20
(3,422 Views)

It does, I ensure the path is created (using the Create Folder vi) if it doesn't already exist before calling Write PNG File.

 

I have also confirmed that the folder has been created afterwards.

 

The VIs are wired such that the create file vi must finish before Write PNG File is called. Is there a chance I need to allow a bit of time between creating the folder and using it? (To let the OS deal with everything?)

 

I can't see how this would be effected by whether the program is running as a built executable or not, however...

0 Kudos
Message 9 of 20
(3,419 Views)

My first thought is that you have some sort of race condition, but you say you have it wired so that the Write File must occur after the Create.  Are you absolutely sure?

 

If you attach a VI, then we can look at it and see if anything looks out of the ordinary with it.

0 Kudos
Message 10 of 20
(3,406 Views)