473,385 Members | 1,720 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,385 software developers and data experts.

Writing a file to my web server

1
I'm using the following c# code to write a file
Expand|Select|Wrap|Line Numbers
  1.      string strVCard = vcg.Generate();
  2.         FileInfo fi = new FileInfo("" + firstn + " " + lastn + "" + ".vcf");      
  3.         StreamWriter sw = fi.CreateText();
  4.         sw.Write(strVCard);
  5.         sw.Flush();
  6.         sw.Close();
  7.  
However this is writing the file to my local c drive in a Microsoft folder here:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

How would i change this code to use Server.MapPath to write the file to my web server as i don't have rights to write the file on the c drive?

Thanks,

Adrian.
Mar 8 '07 #1
1 2055
sicarie
4,677 Expert Mod 4TB
I'm using the following c# code to write a file
Expand|Select|Wrap|Line Numbers
  1.      string strVCard = vcg.Generate();
  2.         FileInfo fi = new FileInfo("" + firstn + " " + lastn + "" + ".vcf");      
  3.         StreamWriter sw = fi.CreateText();
  4.         sw.Write(strVCard);
  5.         sw.Flush();
  6.         sw.Close();
  7.  
However this is writing the file to my local c drive in a Microsoft folder here:

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

How would i change this code to use Server.MapPath to write the file to my web server as i don't have rights to write the file on the c drive?

Thanks,

Adrian.
I'm not entirely sure (you should check this in our .Net forum), but I believe you need to set the DirectoryInfo as well as the FileInfo. Based on quickly scanning the first few docs google returned, it looks like that will allow you to set the path to your web server, and the your FileInfo will start out there.
Mar 8 '07 #2

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

Similar topics

0
by: MB | last post by:
I am writing an FTP Client using the NIO packages because I want to use the non-blocking functionality. I have done this successfully except for the fact that after I "put" an image file to the...
48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
0
by: dvanmil | last post by:
I am in the process of creating my own custom Open File Dialog and was wondering about one thing that should be the final key to my puzzle. Hopefully someone might have some more insights into this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.