Is it possible to copy a file to a destination that includes a shortcut?
-
Is it possible to copy a file to a destination that includes a shortcut link in the path? For example, below the \Staged\ is actually Staged.LNK that points to a diff. server. I normally would use the UNC path but am being asked to do this specifically. User has full rights on the directory as well.
'Statement fails. System.IO.File.Copy("\\Server\Data Dumps\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml", "C:\Documents and Settings\John Doe\Desktop\Staged\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml") 'If I add-in Staged.LNK, the statement fails, without .LNK, VB creates an actual folder called Staged and copies the file into that folder vs. using the shortcut path (to a diff. server). My.Computer.FileSystem.CopyFile("\\Server\Data Dumps\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml", "C:\Documents and Settings\John Doe\Desktop\Staged\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml")
Thanks for any help or comments."There's no such thing as a stupid question, only stupid people." - Mr. Garrison
-
Is it possible to copy a file to a destination that includes a shortcut link in the path? For example, below the \Staged\ is actually Staged.LNK that points to a diff. server. I normally would use the UNC path but am being asked to do this specifically. User has full rights on the directory as well.
'Statement fails. System.IO.File.Copy("\\Server\Data Dumps\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml", "C:\Documents and Settings\John Doe\Desktop\Staged\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml") 'If I add-in Staged.LNK, the statement fails, without .LNK, VB creates an actual folder called Staged and copies the file into that folder vs. using the shortcut path (to a diff. server). My.Computer.FileSystem.CopyFile("\\Server\Data Dumps\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml", "C:\Documents and Settings\John Doe\Desktop\Staged\86355 - Shipment Notice Detail 07.18.2011 11.15.15.108.xml")
Thanks for any help or comments."There's no such thing as a stupid question, only stupid people." - Mr. Garrison
Jon_Boy wrote:
Is it possible to copy a file to a destination that includes a shortcut link in the path?
No, since the .lnk is a file, not a virtual path. The file-system treats it as a file, not as a NTFS Junction Point[^]. As an alternative, you can use VB.NET to read what the .lnk file is pointing to, and concatenate that to your path. You'd need to import a COM-library called "Windows Script Host Object Model", then you could run code similar to this;
Imports IWshRuntimeLibrary
Module ShortcutExample
Sub Main
Dim MyWshShell = new WshShell()
Dim MyShortcut = MyWshShell.CreateShortcut("C:\Users\Eddy\Desktop\SomeFolder.lnk")
Console.WriteLine(MyShortcut.TargetPath)
Console.ReadKey()
End Sub
End ModuleHappy Programming :)
Bastard Programmer from Hell :suss:
-
Jon_Boy wrote:
Is it possible to copy a file to a destination that includes a shortcut link in the path?
No, since the .lnk is a file, not a virtual path. The file-system treats it as a file, not as a NTFS Junction Point[^]. As an alternative, you can use VB.NET to read what the .lnk file is pointing to, and concatenate that to your path. You'd need to import a COM-library called "Windows Script Host Object Model", then you could run code similar to this;
Imports IWshRuntimeLibrary
Module ShortcutExample
Sub Main
Dim MyWshShell = new WshShell()
Dim MyShortcut = MyWshShell.CreateShortcut("C:\Users\Eddy\Desktop\SomeFolder.lnk")
Console.WriteLine(MyShortcut.TargetPath)
Console.ReadKey()
End Sub
End ModuleHappy Programming :)
Bastard Programmer from Hell :suss:
-
Sounds like a plan. Thanks!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison