Hide file via C# & CMD heelp please

This is a discussion on Hide file via C# & CMD heelp please within the C# Programming forums, part of the General Programming Boards category; Hi people, I am having issues with my Hide a file code I am using cmd to hide the file ...

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    2

    Hide file via C# & CMD heelp please

    Hi people,
    I am having issues with my Hide a file code I am using cmd to hide the file and the arguments for when cmd runs are not running? any help would be greatly appreciated

    Code:
     Console.Out.WriteLine("Please enter a url of a file (e.g. ThisFile):");
                string theFile = Console.In.ReadLine();
                Console.Out.WriteLine("If you would like to hide the file press H else press S:");
                string theKey = Console.In.ReadLine();
    
    
                if (theFile == "")
                {
                    Console.Clear();
                    Console.Out.WriteLine("ERROR: Please enter a file to work with...");
                    Console.ReadLine();
                } else if (theKey == "") {
                    Console.Clear();
                    Console.Out.WriteLine("ERROR: Please enter an operation to carry out...");
                    Console.ReadLine();
                }
                else
                    {
    
    
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
    
    
                        if (theKey == "H")
                        {
                            string theCommand = ("attrib -s +h -r " + theFile);
                            ExecuteCmdexe = new ExecuteCmd();
    
    
                            
                        }
                        else if (theKey == "S")
                        {
      
                            Console.Out.WriteLine("wait until H is done...");
                        }
    Obviously the wait till H is done is temporary :L

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    When are you trying to execute the command? I see where you create the string for the command, but nowhere where that is supposed to be executed. (Perhaps it is supposed to be involved with ExecuteCmd?)

  3. #3
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    For that matter, why are you trying to execute an external command? There's already a System.IO.File.SetAttributes() method that would do what you need inside the .NET framework, without the need to spawn a new process just for this.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  4. #4
    Registered User
    Join Date
    Oct 2013
    Posts
    2
    Yeah my bad lol didn't realize I destroyed the process part of my code it was initially:

    Code:
    System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
    proc.StartInfo.FileName = "cmd.exe"
    proc.StartInfo.Arguments = theCommand; 
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardOutput = true; 
    proc.Start();
    Thanks for the replies and heads up with System.IO...
    Any help considering the shell would be appreciated I will use the IO set attributes but this is just something I have to get my head around lol.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What to programmatically hide a file
    By victor43 in forum C++ Programming
    Replies: 5
    Last Post: 02-06-2010, 12:56 AM
  2. File hide in C++
    By rehan in forum C++ Programming
    Replies: 11
    Last Post: 02-25-2008, 02:00 PM
  3. hide what's written to a file
    By kristy in forum C Programming
    Replies: 15
    Last Post: 09-02-2003, 06:46 AM
  4. Linked list; heelp
    By ylph02 in forum C Programming
    Replies: 1
    Last Post: 05-29-2002, 10:22 PM
  5. Please Heelp me ... I gave up
    By NANO in forum C++ Programming
    Replies: 14
    Last Post: 04-21-2002, 09:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21