Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2008, 02:42 PM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default Opening a exterior file

hello there.

I want to open notepad using my application in c#. But it does not complie.

Code:
using System;
using System.Diagnostics;
using System.IO;

namespace StevenHaynesCSharp.DesktopApplication
{
    class DesktopLinks
    {
        public void Main()
        {
            Process.Start(@"C:\windows\notepad.exe");
        }
    }
}
If anyone can help i would be greatfull


 
Old April 29th, 2008, 02:53 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Could you provide the actual compile errors? I imagine the compiler gave you more than "It does not compile."

-Peter
peterlanoie.blog
 
Old April 29th, 2008, 02:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Although, I will venture a guess that the problem may have to do with your Main method.

Typically, the Main() method needs to be static. If this is a console app, it also needs an "args" parameter. It should look something like this:

    static void Main(string[] args)


-Peter
peterlanoie.blog
 
Old April 29th, 2008, 03:01 PM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default

I still get these error. here is the compiler errror

Error 1 The name 'Process' does not exist in the current context C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\Project1\CodeFile1.cs 12 13 Project1


 
Old April 30th, 2008, 04:47 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If I cut and paste the above code into a new class file in a project it compiles with no errors.

/- Sam Judson : Wrox Technical Editor -/
 
Old May 1st, 2008, 12:17 PM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default

This does not work on my computer. What could be the problem

 
Old May 2nd, 2008, 03:03 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What version of C# / Visual Studio are you using? How are you running / compiling this example?

AFAIK, Process is defined in System.dll so I can hardly imagine it's a reference issue....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old May 25th, 2008, 06:10 AM
Authorized User
 
Join Date: Jan 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default

I have found the problem. It is a reference problem. I added System into my reference list for this project and its now a smooth operator.

Doom






Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening file 80240210 Flash (all versions) 0 July 24th, 2007 06:08 PM
Opening a file scoobie Pro Java 1 August 10th, 2006 02:30 PM
file opening jain_mj Visual C++ 0 November 4th, 2005 10:42 AM
file opening silver_cuts Classic ASP Basics 3 June 29th, 2004 01:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.