Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Help with creating a blank document when someone clicks on my program


  • Please log in to reply

#1
paulcomputerman

paulcomputerman

    Member

  • Member
  • PipPipPip
  • 257 posts
Hello,

I have Microsoft Visual Studio 2005 and I would start by saying that I really like it! But I need some help here:
Okay, I have a program that I am building. I would like it when someone clicks on my icon to my program, it will load up my program as well as make a blank.doc on the desktop or some other location. I also Microsoft Access so I can store stuff there if needed.
Can I do this? :tazz:
Paulcomputerman

Edited by paulcomputerman, 24 November 2005 - 11:21 AM.

  • 0

Advertisements


#2
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
paulcomputerman,
You can use the System.IO.File.Create() method in the form load event of your first form(entry point).
The above will work for all version of the .NET framework.
You can also refer Lesson15 on the following page for File related operations in VB.NET:
http://www.programme...2/VB-NET-School
(There is also a corresponding C# link if you want).


If your sure the user will use .NET Framework 2.0 and if your using VB2005, then you can use the cool new "My" namespace.

Edited by darth_ash, 25 November 2005 - 05:55 AM.

  • 0

#3
paulcomputerman

paulcomputerman

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Hello,

I am using Microsoft Visual Studio 2005 in the C# language, sorry if I forgot to say something about that in my first post. Yes, they will be using the .NET Framework 2.00. What is the namespace thing? Can you please help me? also, please provide step-by-step instructions.
  • 0

#4
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
A namespace is just a logical group of classes. You can see the some of the .NET BCL(Base Class Library) (i.e.the pre-defined library calsses in .NET) namespaces being used at the top of your C# code(i.e. the using statements in your code).
System namespace is one of the highest level namespace.
Again in stress that namespace is just a logical group, so it does'nt follow the Inheritance heirachy of the BCL (FYI...The ultimate base class in .NET is Object).

The "MY" namespace is only available to VB2005 and not other languages.
In this case you can use System.IO.File.Create() (here System.IO is the namespace, File is the class and Create its method).

For for info on file handling refer Lesson15 in the following page:
http://www.programme.../2/Les_CSharp_0
  • 0

#5
paulcomputerman

paulcomputerman

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Hello,

Thank you for your information. Is it possible that you could give me step-by-step instructions, because I do not know where I should start.

Thank you,
Paulcomputerman
  • 0

#6
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
Put the following code in the form load of your 1st form:
string userPath = System.Environment.GetEnvironmentVariable("HOME");   //retrives current user directory
System.IO.File.Create(@userPath + @"\Desktop\blank.doc");	//creates the file on desktop

Now for the explanation:
The Desktop folder is different for each user and is physically located at C:\Documents and Settings\UserName\Desktop. So, we will have make code capable of creating a file on desktop no matter what user has logged in or what the folder path is.
Lucky for us, when a user logs-into Windows the current user directory (i.e. C:\Documents and Settings\UserName) is stored in an user environment variable named HOME, by windows.
All we have to do is retrive the value of HOME and concat "\Desktop\blank.doc" to it and finally call the file create method which only requires the path of the file to be created.
  • 0

#7
paulcomputerman

paulcomputerman

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Hello,

Thank you so much! That really helped.

Paulcomputerman
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP