取消
显示结果 
搜索替代 
您的意思是: 

Error 6 when using Write PNG File.vi

已解决!
转到解答

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 项奖励
1 条消息(共 20 条)
5,199 次查看
解答
已被主题作者 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.

2 条消息(共 20 条)
5,189 次查看

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 项奖励
3 条消息(共 20 条)
5,183 次查看

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 项奖励
4 条消息(共 20 条)
5,176 次查看

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 项奖励
5 条消息(共 20 条)
5,173 次查看

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 项奖励
6 条消息(共 20 条)
5,147 次查看

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 项奖励
7 条消息(共 20 条)
5,072 次查看

Hi jr,

 

does that path exist?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 项奖励
8 条消息(共 20 条)
5,062 次查看

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 项奖励
9 条消息(共 20 条)
5,059 次查看

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 项奖励
10 条消息(共 20 条)
5,046 次查看