473,396 Members | 1,784 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.

Access to the path is denied.

Hii i am writting following code for attaching file to the emails it
runs well on the local server but when i run it on domain servert then
it gives an error Access to the path is denied.
can any one tell me what is the problem in it.

public void AttachFilesToEmail(object sender, System.EventArgs e)
{
DataTable dt;
dt = attachedFileTable();
string strFile_Name;
int attachFile_Length;

//if(attachFile_Length==1
if (attachFile1.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile1.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile2.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile2.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile3.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile3.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}

}
if (attachFile4.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile4.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile5.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile5.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}

Oct 16 '06 #1
1 3247
If I can take a guess, you are developing on Windows XP and deploying to
Windows Server 2003. The file you are attempting to attach exists in a
folder outside of the website (instead of something like <root>/attachments
it is c:\attachments).

If so, you have choices:
1. Turn off the transversal security bits and allow the website to read from
any folder (this is also known as "destroy the security of your machine")
2. Set up a windows service to feed the file
3. Move the attachment files to the website directory structure
4. Move the attachment "file" to the database

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"Santosh" <Sa***************@yahoo.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Hii i am writting following code for attaching file to the emails it
runs well on the local server but when i run it on domain servert then
it gives an error Access to the path is denied.
can any one tell me what is the problem in it.

public void AttachFilesToEmail(object sender, System.EventArgs e)
{
DataTable dt;
dt = attachedFileTable();
string strFile_Name;
int attachFile_Length;

//if(attachFile_Length==1
if (attachFile1.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile1.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile2.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile2.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile3.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile3.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}

}
if (attachFile4.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile4.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}
if (attachFile5.PostedFile.ContentLength 0)
{
HttpPostedFile attFile1 = attachFile5.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length 0)
{
strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFi le_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFil e_Length).ToString()+
" Bytes");
}
}

Oct 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ----------------------------------------------------------------------------...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
0
by: Goran | last post by:
Hi I have created a very simple ASP.Net application that only consists of a CrystalReports Viewer, that has been connected to a .rpt file. When the page is loaded in the browser, the following...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
1
by: Duffman | last post by:
Hi, I have what seems to be a common problem, but the solutions I've found don't seem to work. I would like to use a web service to create a file at a UNC location in a shared file. Currently...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
2
by: stephen | last post by:
Hi, I am getting an Error "Access to the path...... is denied" Error. I have an web app and I am creating a log file to write the error info. If I have the absolute path...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
0
by: p.thorn.ru | last post by:
Hello, I am running db2 express-c 9.5 under linux (fedora 7), and my error log frequently shows messages like these: 2008-01-08-18.30.01.952964+180 I651334G1048 LEVEL: Error (OS) PID ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.