0

I have some code that uses processes to open files. It suddenly stopped working, and when I started investigating, I found it was due to the length/weirdness (special chars) of the path.

If I move the file to a different directory and/or rename it, it opens without problems. Also, if I create an identical directory on another computer and run the same code, it works.

The code I used to start the process was as follows (but it didn't matter if I used Process.start(path) either.

Dim pToStart as ProcessStartInfo
pToStart = New ProcessStartInfo(filepath)
pToStart.WindowStyle = ProcessWindowStyle.Maximized
pToStart.UseShellExecute = True
System.Diagnostics.Process.Start(pToStart)

I can't disclose the exact path names (as the file names have some confidential info), but I can give rough ones. "x" means alphanumeric character, "z" is just the extension.

Working:

  • C:\Users\User\Downloads\xxxxxxx.zzz
  • C:\Directory\First Last\xxxxx_xxxx_xxxx_xxxx_xx_x.zzz

Not Working:

  • C:\Directory\First Last\xx_xxxxx_xxxxx_x%_xxx x-xx.x_xx.zzz
  • C:\Directory\First Last\xx_xxxxx_xxxxx_x%_xxx x-xx.x_xx.zzz

The computer looks like it is trying to open something, but nothing happens. The process is started briefly in task manager and then ends.

Thanks.

Sastreen
  • 597
  • 4
  • 13

1 Answers1

0

see this post about retrieving equivalent short file names:

https://stackoverflow.com/questions/12727806/file-shortpath-for-vb-net

and then see if you can work with the short filename.

Community
  • 1
  • 1
Rob
  • 3,488
  • 3
  • 32
  • 27