473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

File creation does not work in Vista using C#

Ajm113
161 100+
For some reason I can't create files in .Net and It mite be the permissions with the new Vista so I am lost in a short term.

Here is my code:
Expand|Select|Wrap|Line Numbers
  1.         private void OnConfigure(object sender, System.EventArgs e)
  2.         {
  3.             string path32 = @"Starter1.bat";
  4.  
  5.                 if (System.IO.File.Exists(path32))
  6.                 {
  7.  
  8.             OpenFileDialog openFile1 = new OpenFileDialog();
  9.  
  10.             // Initialize the OpenFileDialog to look for text files:
  11.             openFile1.Filter = "Executable Files|*.exe";
  12.             openFile1.InitialDirectory = @"C:\";
  13.             openFile1.Title = "Select a Executable!";
  14.             openFile1.RestoreDirectory = false;
  15.  
  16.             if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  17.             {
  18.                 System.IO.StreamWriter file = new System.IO.StreamWriter(@"Starter1.bat");
  19.                     //w.WriteLine("START /MAX" + openFile1.FileName);
  20.                    file.Write("Hello, World!");
  21.  
  22.                    file.Close();
  23.  
  24.                 System.Windows.Forms.MessageBox.Show("The path:\n" + openFile1.FileName + " was written in the .bat file!", "Doom3 Scripter 2.0");
  25.             }
  26.  
  27.                }else{
  28.                    System.Windows.Forms.MessageBox.Show("Can't Find \"Start1.bat\"!", "Doom3 Scripter 2.0", MessageBoxButtons.OK, MessageBoxIcon.Error);
  29.                 }
  30.         }
I get no errors on Visual and on my program too so I don't know what it is doing! Can someone run a test on this or give me some help?
Sep 13 '07 #1
6 3115
Shashi Sadasivan
1,435 Expert 1GB
Hi,
Im running Vista business...
works perfectly for me mate

cheers
Sep 13 '07 #2
Ajm113
161 100+
How did you have it set up with your files? Where did you place the test file at?

Because I am am using this on a windows form and it seems not to work.
Sep 13 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
I used it as windows forms.
had a blank form there, but put your code into the form class, and called it at the constructor.
Are you getting any exceptions?
till which part is your code working?
Sep 13 '07 #4
Ajm113
161 100+
Well everything is working for the exception of the openDialog. Because I commented out everything in that event for the exception where it writes the file and it works! The only thing that is messing the script up is the Open Dialog area. :0
Sep 13 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
Well everything is working for the exception of the openDialog. Because I commented out everything in that event for the exception where it writes the file and it works! The only thing that is messing the script up is the Open Dialog area. :0
hmm...
try building a new project.
something seems wrong with the reference of windows.forms
Sep 13 '07 #6
Ajm113
161 100+
Yeah its it.
How can I restart or reload references?
Sep 13 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time?...
0
by: yxq | last post by:
Hello, The function File.Delete will not work in Windows Vista 5365, why? And the API SHFileOperation also not work in Vista, how to delete a file in Vista? Thank you
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
19
by: =?Utf-8?B?TWlrZTk5MDA=?= | last post by:
When there is a shortcut of our app on the desctop, the app is not run until all the security in control panel of win vista is cleared. What to do to not have this problem. We do not want to tell...
10
by: strife | last post by:
Hey everyone, I was making a program for a class, and I ran into a problem that is driving me crazy. I first suspected Vista, and since I am not home I cannot verify if it just my Vista...
5
by: | last post by:
Hello, I am wrtting a program that does some sound effects... the files are stored in a subfolder in the application folder... and I check the existence of the files before calling the method to...
7
by: =?Utf-8?B?UGFycm90?= | last post by:
I am receiving a "file is being used by another process" error message whenever I try to access a text file that I had previously created and then closed. This only happens when I test in a...
0
by: Prajaktaj | last post by:
Hi All, I have an application which records the sound using lame encoder. It works perfectly fine means I am able to record the sound on all Operating systems but when I tried the same on Vista...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.