C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Windows »

Open files


Posted Date: 03 Nov 2009      Posted By: Elz      Member Level: Gold     Points: 1   Responses: 5



Hi all,

How to open files depending on their extensions
if filename has .txt extension then it should be open using notepad,if it is doc,opens in word.

How to do that using c#.net?





Responses

Author: venkatesan    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

you have to check the extension then pass the Content type

else use octetstream it will automatically open the specific file.

Regards,
M.Venkatesan.
Dot Net Code Snippets



Author: Elz    03 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi venkatesan,

Can you give me sample code?



Author: Danasegarane.A    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

This method will open the file with their default extension


System.Diagnostics.Process.Start("Filenamewithpath")



System.Diagnostics.Process.Start("D:\t.txt")


If it is a Notepad file it will be opened with Notepad by default
If it is a Word File it will be opened with Winword

Please note that if there is no associated program then you will get error. You need to handle that also

Thanks and Regards,
Danasegarane Arunachalam



Author: Anuraj    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Try

Process.Start("Filename");

Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Author: Elz    03 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi all

Thanks for the post



Post Reply
You must Sign In to post a response.
Next : How to draw chart in crystal report in vb.net?
Previous : Passing the parameters from one page to other page on windows
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use