| | |
how to create shortcuts?
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Feb 2008
Posts: 82
Reputation:
Solved Threads: 4
Thanks for reply LizR.
Of course I googled that, and I had a little problem I'll tell you now. I made a reference to "Windows Script Host Object Model", then I included IWshRuntimeLibrary and I made a button for testing, so that when I click it, process for creating the shortcut starts, like this:
The problem is that I use File.AppendAllText() method to write to file and I got this error:
" 'File' is an ambiguous reference between 'System.IO.File' and 'IWshRuntimeLibrary.File' ".
It seems to be a little conflict. So, don't worry, I don't wanna lose your time with nothing; I told you now the main problem in my program. And sorry for not pointing to the exact problem. I'll go now; in 7 hours I'm back.
Of course I googled that, and I had a little problem I'll tell you now. I made a reference to "Windows Script Host Object Model", then I included IWshRuntimeLibrary and I made a button for testing, so that when I click it, process for creating the shortcut starts, like this:
C# Syntax (Toggle Plain Text)
private WshShellClass WshShell; private void button3_Click(object sender, EventArgs e) { // Create a new instance of WshShellClass WshShell = new WshShellClass(); // Create the shortcut IWshRuntimeLibrary.IWshShortcut MyShortcut; // Choose the path for the shortcut MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\Documents and Settings\All Users\Desktop\cLchecker.lnk"); // Where the shortcut should point to MyShortcut.TargetPath = Application.ExecutablePath; // Description for the shortcut MyShortcut.Description = "Launch cLchecker"; // Location for the shortcut's icon MyShortcut.IconLocation = Application.StartupPath + @"\cLchecker.ico"; // Create the shortcut at the given path MyShortcut.Save(); }
" 'File' is an ambiguous reference between 'System.IO.File' and 'IWshRuntimeLibrary.File' ".
It seems to be a little conflict. So, don't worry, I don't wanna lose your time with nothing; I told you now the main problem in my program. And sorry for not pointing to the exact problem. I'll go now; in 7 hours I'm back.
Last edited by Clawsy; Oct 15th, 2008 at 8:26 am.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
You dont show the code you're using so we're only guessing..
Your short cut looks like it should appear after your code above.. Whats the file bit for? something else?
Your short cut looks like it should appear after your code above.. Whats the file bit for? something else?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
what you have to do is remove "using System.IO;" from the top of your class, and everytime you need to use System.IO.File you will have to type the full namespace. problem is that when you import the namespace for the object that creates your shortcut you share its namespace scope with the "File" namespace scope of the System.IO, so removing the using block at the top of your class fixes the problem.
Happy Coding!
Happy Coding!
![]() |
Similar Threads
- Internet Explorer & Windows Explorer (desktop shortcuts) Won't Load! (Viruses, Spyware and other Nasties)
- For some reason program installations cannot create new start menu shortcuts... (Windows NT / 2000 / XP)
- Internet Explorer problem (Viruses, Spyware and other Nasties)
- Missing Shortcuts on Startup (With Hijack Log) (Viruses, Spyware and other Nasties)
- Add an Item to the Send To Menu (Windows tips 'n' tweaks)
- Create a Keyboard Shortcut to Open a Folder (Windows tips 'n' tweaks)
- Win xp destop problems (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: What's wrong with this program?
- Next Thread: need help with a custom web browser
| Thread Tools | Search this Thread |
.net access algorithm array asp.net bitmap box broadcast c# check checkbox client combobox control conversion csharp database datagrid datagridview dataset datetime dbconnection decryption degrees design developer draganddrop drawing encryption enum eventhandlers excel file firefox focus form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install interface java libraries list loop marshalbyrefobject math mouseclick movingimage mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml






