Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Please Help....How to open a file in application?

Please Help....How to open a file in application?

Scheduled Pinned Locked Moved C#
csharpvisual-studiotoolshelptutorial
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lyfkcd
    wrote on last edited by
    #1

    Really need help guys!! Am just a newby in .Net programming, i am using visual studio 2005 and studying C# programming language. I am building a utility software that would need to be opened by clicking or double-clicking the file built by my application using its own file extensions, much like zip files in windows explorer loading on WinZip etc... Really need help... Please anyone..Sample C# 2005 codes would be very much appreciated. Thank you!!! .............

    S A 2 Replies Last reply
    0
    • L Lyfkcd

      Really need help guys!! Am just a newby in .Net programming, i am using visual studio 2005 and studying C# programming language. I am building a utility software that would need to be opened by clicking or double-clicking the file built by my application using its own file extensions, much like zip files in windows explorer loading on WinZip etc... Really need help... Please anyone..Sample C# 2005 codes would be very much appreciated. Thank you!!! .............

      S Offline
      S Offline
      Seishin
      wrote on last edited by
      #2

      [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if(args == null || args.Length == 0) Application.Run(new Form1()); else Application.Run(new Form1(args[0])); } args is the parameter list. if you open app through file the first parameter is the file name.. then you can do whatever you want with it..

      life is study!!!

      L 2 Replies Last reply
      0
      • L Lyfkcd

        Really need help guys!! Am just a newby in .Net programming, i am using visual studio 2005 and studying C# programming language. I am building a utility software that would need to be opened by clicking or double-clicking the file built by my application using its own file extensions, much like zip files in windows explorer loading on WinZip etc... Really need help... Please anyone..Sample C# 2005 codes would be very much appreciated. Thank you!!! .............

        A Offline
        A Offline
        Abisodun
        wrote on last edited by
        #3

        I think you need the File Types Editor in your deployment setup project: http://msdn2.microsoft.com/en-us/library/c219k91z(VS.80).aspx[^]

        L 1 Reply Last reply
        0
        • S Seishin

          [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if(args == null || args.Length == 0) Application.Run(new Form1()); else Application.Run(new Form1(args[0])); } args is the parameter list. if you open app through file the first parameter is the file name.. then you can do whatever you want with it..

          life is study!!!

          L Offline
          L Offline
          Lyfkcd
          wrote on last edited by
          #4

          "args is the parameter list. if you open app through file the first parameter is the file name.. then you can do whatever you want with it.. " -what do you mean, i'm sorry i don't get it..in vs 2005 these lines are included in the Program.cs file, isn't it? These are my codes in my main form using the Form_Load Event. RegistryKey rk = Registry.ClassesRoot.CreateSubKey(".sis",RegistryKeyPermissionCheck.ReadWriteSubTree); rk.SetValue("Content Type", "application/x-sis"); rk.SetValue("PerceivedType", "file collections"); rk.SetValue("", "SIS"); rk.CreateSubKey("OpenWithList"); RegistryKey rk2 = Registry.ClassesRoot.CreateSubKey("SIS", RegistryKeyPermissionCheck.ReadWriteSubTree); rk2.SetValue("", "SIS File"); rk2.CreateSubKey("DefaultIcon",RegistryKeyPermissionCheck.ReadWriteSubTree); try { RegistryKey rk3 = Registry.ClassesRoot.OpenSubKey("SIS", true).OpenSubKey("DefaultIcon", true); rk3.SetValue("", "C:/sis.ico"); RegistryKey rk4 = Registry.ClassesRoot.OpenSubKey("SIS", true); rk4.CreateSubKey("shell", RegistryKeyPermissionCheck.ReadWriteSubTree); RegistryKey rk5 = Registry.ClassesRoot.OpenSubKey("SIS", true).OpenSubKey("shell", true); rk5.CreateSubKey("open", RegistryKeyPermissionCheck.ReadWriteSubTree); RegistryKey rk51 = Registry.ClassesRoot.OpenSubKey("SIS", true).OpenSubKey("shell", true).OpenSubKey("open", true); rk51.SetValue("", "Open with &SIS"); RegistryKey rk6 = Registry.ClassesRoot.OpenSubKey("SIS", true).OpenSubKey("shell", true).OpenSubKey("open",true); rk6.CreateSubKey("command", RegistryKeyPermissionCheck.ReadWriteSubTree); RegistryKey rk66 = Registry.ClassesRoot.OpenSubKey("SIS", true).OpenSubKey("shell", true).OpenSubKey("open", true).OpenSubKey("command", true); rk66.SetValue("", "C:/SIS.exe"); RegistryKey rkapp = Registry.ClassesRoot.OpenSubKey("Applications", true); rkapp.CreateSubKey("SIS.exe", RegistryKeyPermissionCheck.ReadWriteSubTree); RegistryKey rkapp2 = Registry.ClassesRoot.OpenSubKey("Applications", true).OpenSubKey("SIS.exe", true); rkapp2.CreateSubKey("shell", RegistryKeyPermissionCheck.ReadWriteSubTree); RegistryKey rkapp3 = Registry.ClassesRoot.OpenSubKey("Applications", true)

          1 Reply Last reply
          0
          • A Abisodun

            I think you need the File Types Editor in your deployment setup project: http://msdn2.microsoft.com/en-us/library/c219k91z(VS.80).aspx[^]

            L Offline
            L Offline
            Lyfkcd
            wrote on last edited by
            #5

            I've posted my block of codes, please try to look deep into it, im gettin the access denied upon clicking or right clicking and choosing "Open with SIS", the registered file with my own file extensions still have unknown applications on its properties.... I need a way on these without deployment yet. Is there any other way? PLEASE....

            A 1 Reply Last reply
            0
            • L Lyfkcd

              I've posted my block of codes, please try to look deep into it, im gettin the access denied upon clicking or right clicking and choosing "Open with SIS", the registered file with my own file extensions still have unknown applications on its properties.... I need a way on these without deployment yet. Is there any other way? PLEASE....

              A Offline
              A Offline
              Abisodun
              wrote on last edited by
              #6

              Sorry I'm not really familiar with the necessary registry updates but this might help you: http://www.codeproject.com/shell/cgfiletype.asp[^]

              L 1 Reply Last reply
              0
              • A Abisodun

                Sorry I'm not really familiar with the necessary registry updates but this might help you: http://www.codeproject.com/shell/cgfiletype.asp[^]

                L Offline
                L Offline
                Lyfkcd
                wrote on last edited by
                #7

                Thank you so much anyway..., but favor please, if you'd have d idea on how to manage these problems written in C#, please do "message me here"..Tnx.

                A 1 Reply Last reply
                0
                • L Lyfkcd

                  Thank you so much anyway..., but favor please, if you'd have d idea on how to manage these problems written in C#, please do "message me here"..Tnx.

                  A Offline
                  A Offline
                  Abisodun
                  wrote on last edited by
                  #8

                  Seems you are already on the right track. Remember your application must open the file using the arg[0](path to your file) parameter from the Main method. static void Main(strings[] args) { if (args.Length <> 0) Open(args[0]);//implement Open else Application.Run(new Form1()); } I would do the following: 1) For testing purposes use the setup project (Set Open as default etc) and confirm the registry entries created by your setup project. Confirm double-click works. 2) Use C# to update the registry - compare with setup project entries to confirm what entries you may be missing. Best of luck!!

                  L 1 Reply Last reply
                  0
                  • A Abisodun

                    Seems you are already on the right track. Remember your application must open the file using the arg[0](path to your file) parameter from the Main method. static void Main(strings[] args) { if (args.Length <> 0) Open(args[0]);//implement Open else Application.Run(new Form1()); } I would do the following: 1) For testing purposes use the setup project (Set Open as default etc) and confirm the registry entries created by your setup project. Confirm double-click works. 2) Use C# to update the registry - compare with setup project entries to confirm what entries you may be missing. Best of luck!!

                    L Offline
                    L Offline
                    Lyfkcd
                    wrote on last edited by
                    #9

                    Thank you sooo much!!!

                    1 Reply Last reply
                    0
                    • S Seishin

                      [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if(args == null || args.Length == 0) Application.Run(new Form1()); else Application.Run(new Form1(args[0])); } args is the parameter list. if you open app through file the first parameter is the file name.. then you can do whatever you want with it..

                      life is study!!!

                      L Offline
                      L Offline
                      Lyfkcd
                      wrote on last edited by
                      #10

                      I kinda followed your message last time, quite got it eventually.... Thanx sooo much for the help... XS: Yes, Life is study...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups