Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Saturday, March 31, 2012

System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."

Does anyone know what I can do about these issues?Try also

graphicOrig.Dispose();

--Daniel
http://staff.newtelligence.com/danielf/

--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."

Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:

string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.F ileName); // fileUpload is
the id of fileupload html control

Zeeshan
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.

graphicOrig.Dispose();
rectOrig.Dispose();

Zeeshan.
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
thanks
it worked !

"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> > Hi,
> > I have this question.
> > When I use the FileUpload WebControl to post an Image (= SourceFile) that
> > I
> > want to resize and write to the server, I keep getting this situation.
> > If that SourceFile is located in My Documents (as in "C:\Documents and
> > Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> > a
> > 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> > from
> > "C:\Folder\imgName".
> > What can I do about this ?
> > Actually I found a workaround, but this gives me an error as well...
> > I can save the PostedFile like this
> > PostedFile.SaveAs(imgPath + "DummyName");
> > After which I can do these steps without any problem
> > System.Drawing.Image srcImage =
> > System.Drawing.Image.FromFile(imgPath + DummyName);
> > Graphics graphicOrig = Graphics.FromImage(srcImage);
> > graphicOrig.CompositingQuality =
> > CompositingQuality.HighQuality;
> > graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> > graphicOrig.InterpolationMode =
> > InterpolationMode.HighQualityBicubic;
> > Rectangle rectOrig = new Rectangle();
> > graphicOrig.DrawImage(srcImage, rectOrig);
> > srcImage.Save(NewFileName, ImageFormat.Jpeg);
> > srcImage.Dispose();
> > The final srcImage is perfect, and everything I need but when I want to do
> > this
> > File.Delete(imgPath + dummyName);
> > I get the IOException that File cannot be deleted:
> > "The process cannot access the file 'ImgPAth\dummyName' because it is
> > being
> > used by another process."
> > Does anyone know what I can do about these issues?
>
thanks
it worked !

"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

System.drawing.image

Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?Try also
graphicOrig.Dispose();
--Daniel
http://staff.newtelligence.com/danielf/
--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image
Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."
Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:
string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.FileName); // fileUpload is
the id of fileupload html control
Zeeshan
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.
graphicOrig.Dispose();
rectOrig.Dispose();
Zeeshan.
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
thanks
it worked !
"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
>
>
thanks
it worked !
"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

system.enterpriseservices.dll error

I am running a web app on w2k3/IIS 6.0/ASP.net 2.0. This app runs fine on a different server. The error message I get is

Compiler Error Message:CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found

I have seen solutions to remove the "<identity impersonate="true" />" setting from the web.config file. That has not been helpful. Another solution was to delete the system.enterpriseservices.dll from C:\Windows\assembly. I have deleted the file, copied a new .dll, and that did not work. I have reinstalled IIS and ASP.Net 2.0 as well. So far, no dice. Any other ideas are greatly welcomed!


AJ

Hello AJ,

This may be a dumb question, but is the assembly in the GAC on the deployment server? If it isn't, you should be able to add it by running "gacutil /if System.EnterpriseServices.dll" using the 2.0 version of gacutil.exe.

HTH,
Clay


Clay,

Thanks for the response. I just got the problem figured out today.

The file permissions were screwed up. Users did not have read and execute permissions to this folder:
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790

After I fixed that I got a similar error message as before but it mentioned a system.enterpriseServices.Wrapper.dll and found out that this file was missing
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790\System.EnterpriseServices.Wrapper.dll

Now it is running like a champ!

AJ

System.IndexOutOfRangeException

I'm seeing the above error message appear on a web form. All the formcode-behind does is grab data from a SQL Server db (2005 Beta) andwrite it out in specfied controls.
The line that throws up the error is the following:
<code>
Line 150: txtCoDeath1a.Text = dtr("COD1a")
</code>
'Dtr' is simply a datareader that has been initialised previously. Iknow I should be checking for nulls in the db, but that isn't theproblem in this instant as the record I'm grabbing does have data forthe field 'COD1a'. It's of type nvarchar, length 150.
I've googled this error and have not found anything that seems directly relevant.
I'm using VB.
Any help much appreciated.

try putting this before your code

if dtr.Read then
dtr("COD1a")
end if


Sorry Chris, I should've posted more of my code.
I already have those lines in the code.
Any other ideas?

Try this

if not System.DBNull(dtr("COD1a")) then

txtCoDeath1a.Text = dtr("COD1a")

end if

Could you post more of your code? Are results coming back from the database? Is there a field called COD1a?


Thanks for the help guys, but I've located the source of theproblem. Very simple; I'd misnamed 'Cod1a'. Its actually 'CodIa'. Spotthe difference? Neither did I for a while!
<Sheepish> Sorry and thanks again.

Wednesday, March 28, 2012

System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning

I have an ASP.NET application which displays the directories & files in a
specified directory on the server. I use the
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to
retrieve the lists of files and directories. I have two very similar
versions of this that I am debugging, both of which use the methods
mentioned above. However, one of them is returning the contents of the
specified directory and the other is returning the contents of the project's
directory. I have checked to see what values are used by and returned by
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles(), and
they use the values I expect, but do not return the directories and files in
that directory. What is going on here?"Nathan Sokalski" <njsokalski@.hotmail.comwrote in message
news:ehSNlnJ8HHA.5164@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>I have an ASP.NET application which displays the directories & files in a
>specified directory on the server. I use the
>System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to
>retrieve the lists of files and directories. I have two very similar
>versions of this that I am debugging, both of which use the methods
>mentioned above. However, one of them is returning the contents of the
>specified directory and the other is returning the contents of the
>project's directory. I have checked to see what values are used by and
>returned by System.IO.Directory.GetDirectories() and
>System.IO.Directory.GetFiles(), and they use the values I expect, but do
>not return the directories and files in that directory. What is going on
>here?


[X-posting removed]

Please show your code...

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
On Sep 6, 11:23 am, "Nathan Sokalski" <njsokal...@.hotmail.comwrote:

Quote:

Originally Posted by

I have an ASP.NET application which displays the directories & files in a
specified directory on the server. I use the
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to
retrieve the lists of files and directories. I have two very similar
versions of this that I am debugging, both of which use the methods
mentioned above. However, one of them is returning the contents of the
specified directory and the other is returning the contents of the project's
directory. I have checked to see what values are used by and returned by
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles(), and
they use the values I expect, but do not return the directories and files in
that directory. What is going on here?


Both of those methods work fine for me. You will need to post some
actual code that is having the problem.

System.io.File

When using the File object how do you now whether the path you are putting, is the path of a file on the server or the path of a file on the client machine.

I want to transfer a file from the client machine to the server, does anyone know if the File object is suited for this?I guess the real question there is where did you get the path from.

If the path came from the Posted File - then it is most likely the file path / name from the client not and is not valid for saving on the server
What do you mean when you say where the path came from, what if i hard code a file path to be e.g c:/intepub/newfolder/file.txt

If i put that path into a file object, would that look at c: on the server or client?
It's always a Path on your server or another machine in your network, over which you (or rather the ASPNET worker process or some other user you let the worker process impersonate) have rights to access.

The only time you handle a client path, is when someone has uploaded a file to your server.
Ok, but thats what i want to do using asp.net, i want to allow users to upload a file from their machine to the server. I have done this successfully using Java, but wanted to know if its possible using .net
It's extremely easy using .Net. One line of code will suffice in this very simple scenario:


<%@. Page Language="VB" %>
<%@. import Namespace="System.IO" %>
<script runat="server">
Sub Button_Click( obj As Object, evnt As EventArgs )
inpFileName.PostedFile.SaveAs( Server.MapPath("") & Path.GetFileName(inpFileName.PostedFile.FileName) )
End Sub
</script>
<html>
<head>
<title>Upload file</title>
</head>
<body>
<form enctype="multipart/form-data" runat="Server">
<input id="inpFileName" type="file" runat="Server" /><br>
<asp:Button id="btnFileUp" onclick="Button_Click" Runat="Server" Text="Upload file" /></form>
</body>
</html>

This will save an uploaded file to the root of your web application. Remember to grant rights to write to the physical folder for the ASPNET account. By default the max file size to be uploaded using .Net is set to 4 mb (4096 kb). If you need to up this size, you set it in your application's Web.config file using:

<httpRuntime maxRequestLength="<size in kb you wish to allow>" />

Thanks very much

System.IO.File class and IP paths?

I try to use System.IO.File.Copy where the source is
"\\10.100.100.1\myfolder\test.txt"

When running the aspx file on the server (the server is
also the client) it works, but when using another NT
client it does not work.
The err.description says "Could not find file ..."
System.IO.File.Exists return false here.

But If I manually paste in \\10.100.100.1
\myfolder\test.txt in the IE address field and press "Go"
the file is found.

Strange or not?Hi,

I don't think that the default asp.net user got rights to access network
resources.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

System.IO.FileNotFoundException, When Accessing file in remote ser

I am trying to access files in a remote server from my ASP.NET application,
it is giving System.IO.FileNotFoundException error. I tried mapping that
server location like "H:\ErrorLogs\error.log" still it gives error. I tried
even giving the server name and directory like
"\\server_name\\Directory\\file.log" still it gives file not found exception.
Does anyone help me fix this.

Thanksuse \\machineIP\sharename\filename

"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks
asp.net normally does not have permission to any network resources. to
access a networked drive, you will have to make the asp_net account a domain
account, or specify the userName and password of a domain account in the web
config <impersonate> tag.

-- bruce (sqlwork.com)

"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks

System.IO.FileNotFoundException, When Accessing file in remote ser

I am trying to access files in a remote server from my ASP.NET application,
it is giving System.IO.FileNotFoundException error. I tried mapping that
server location like "H:\ErrorLogs\error.log" still it gives error. I tried
even giving the server name and directory like
"\\server_name\\Directory\\file.log" still it gives file not found exception
.
Does anyone help me fix this.
Thanksuse \\machineIP\sharename\filename
"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks
asp.net normally does not have permission to any network resources. to
access a networked drive, you will have to make the asp_net account a domain
account, or specify the userName and password of a domain account in the web
config <impersonate> tag.
-- bruce (sqlwork.com)
"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks

System.IO.IOException

Hi all,

Yesterday we upgraded our server to the 1.1 Framework. (from 1.0)
Our project was also converted in Visual Studio to 1.1

Since we have uploaded the project, we are getting an error with one of our
pages which is trying to read a list of files from a network share and
populate a dropdownlist.

The error is:

System.IO.IOException: The specified network name is no longer available.

OR

System.IO.IOException: The specified network password is not correct.

The code is:

Dim fileEntries As String() = Directory.GetFiles(targetDirectory)

where targetdirectory is "\\192.168.1.1\data\General\Documents\"

If we try to view the page on our own machines ie http://localhost the page
works fine!!

So is there any fixes/ideas why this is happening!!

Thanks!How would you get TWO different error messages from the same code?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Krissy" <krissi___@.hotmail.com> wrote in message
news:3f27704b@.quokka.wn.com.au...
> Hi all,
> Yesterday we upgraded our server to the 1.1 Framework. (from 1.0)
> Our project was also converted in Visual Studio to 1.1
> Since we have uploaded the project, we are getting an error with one of
our
> pages which is trying to read a list of files from a network share and
> populate a dropdownlist.
> The error is:
> System.IO.IOException: The specified network name is no longer available.
> OR
> System.IO.IOException: The specified network password is not correct.
>
> The code is:
> Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
> where targetdirectory is "\\192.168.1.1\data\General\Documents\"
>
> If we try to view the page on our own machines ie http://localhost the
page
> works fine!!
> So is there any fixes/ideas why this is happening!!
> Thanks!
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:ONRU7dpVDHA.2316@.TK2MSFTNGP09.phx.gbl...
> How would you get TWO different error messages from the same code?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> http://www.takempis.com
> Complex things are made up of
> lots of simple things.
> "Krissy" <krissi___@.hotmail.com> wrote in message
> news:3f27704b@.quokka.wn.com.au...
> > Hi all,
> > Yesterday we upgraded our server to the 1.1 Framework. (from 1.0)
> > Our project was also converted in Visual Studio to 1.1
> > Since we have uploaded the project, we are getting an error with one of
> our
> > pages which is trying to read a list of files from a network share and
> > populate a dropdownlist.
> > The error is:
> > System.IO.IOException: The specified network name is no longer
available.
> > OR
> > System.IO.IOException: The specified network password is not correct.
> > The code is:
> > Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
> > where targetdirectory is "\\192.168.1.1\data\General\Documents\"
> > If we try to view the page on our own machines ie http://localhost the
> page
> > works fine!!
> > So is there any fixes/ideas why this is happening!!
> > Thanks!

If I knew that then I wouldn't have the problem ;)

System.IO.IOException: Cannot create a file when that file already exists.

Getting the following error on my production server whether the file exists
or not:

"System.IO.IOException: Cannot create a file when that file already exists."

Here's the code generating the error (seems to be happening when I try
creating a directory)

If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
lblerror.Text = lblerror.Text & "Unable to build physical path. " &
txt_name.Text & " & Contact Dev Team.<BR>"
Else
dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)

This code runs fine on my development server (only the path is c:\blah\blah
instead of S). Also, my production server has failover cluser, and the s
drive is the failover drive. I can't imagine that could be a problem, but
thought I would mention it.

Asside from that, the only other thing I can think of is that the framework
version on my dev box says 1.1, and the one on my production server says:
1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
issue (i've even tried as domain admin)

I would appreciate any help on this, as I'm out of ideas, and can find no
other documentation on this.
- ChadHi,

the default user that runs web application (system) dont has rights to
access network resources.

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I agree with Natty. The problem you are having is most likely caused by
having no right to access network resources. Willy address a similar
problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.

HTH,
-Allen

Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com

-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| Subject: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Wed, 6 Aug 2003 17:08:27 -0400
| Lines: 29
|
| Getting the following error on my production server whether the file
exists
| or not:
|
| "System.IO.IOException: Cannot create a file when that file already
exists."
|
| Here's the code generating the error (seems to be happening when I try
| creating a directory)
|
| If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| lblerror.Text = lblerror.Text & "Unable to build physical path. "
&
| txt_name.Text & " & Contact Dev Team.<BR>"
| Else
| dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
|
| This code runs fine on my development server (only the path is
c:\blah\blah
| instead of S). Also, my production server has failover cluser, and the s
| drive is the failover drive. I can't imagine that could be a problem, but
| thought I would mention it.
|
| Asside from that, the only other thing I can think of is that the
framework
| version on my dev box says 1.1, and the one on my production server says:
| 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
| issue (i've even tried as domain admin)
|
| I would appreciate any help on this, as I'm out of ideas, and can find no
| other documentation on this.
| - Chad
|
|
|
Thanks for the response.

I understand that, but I'm trying to create a directory on the local drive.
This isn't a mapped share. The drive is physically present on the web
server, and if that web server fails, the other system physically takes over
the drive (ie, a cluster). I've also added the local ASPNET account to the
NTFS permissions on the folder, and it still fails.

- Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> I agree with Natty. The problem you are having is most likely caused by
> having no right to access network resources. Willy address a similar
> problem before. See
http://groups.google.com/groups?q=S...et&start=10&hl=
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> HTH,
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | Subject: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | Lines: 29
> |
> | Getting the following error on my production server whether the file
> exists
> | or not:
> |
> | "System.IO.IOException: Cannot create a file when that file already
> exists."
> |
> | Here's the code generating the error (seems to be happening when I try
> | creating a directory)
> |
> | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | lblerror.Text = lblerror.Text & "Unable to build physical path.
"
> &
> | txt_name.Text & " & Contact Dev Team.<BR>"
> | Else
> | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> |
> | This code runs fine on my development server (only the path is
> c:\blah\blah
> | instead of S). Also, my production server has failover cluser, and the
s
> | drive is the failover drive. I can't imagine that could be a problem,
but
> | thought I would mention it.
> |
> | Asside from that, the only other thing I can think of is that the
> framework
> | version on my dev box says 1.1, and the one on my production server
says:
> | 1.0.37 - surely that's not the cause is it? Permissions shouldn't be an
> | issue (i've even tried as domain admin)
> |
> | I would appreciate any help on this, as I'm out of ideas, and can find
no
> | other documentation on this.
> | - Chad
> |
> |
> |
It doesn't work creating folders under the same directory as the web
application... same issue.

I'm going to try figuring out why that server is showing that it's running
version 1.03 of the dotnet framework. It shows that v1.1 was installed.

Thanks,
Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> Try creating a directory in your code under the folder where your web
> application resides. Does it works? In addition, you may want to verify
the
> account your web application is running under. Please download tokedump
> written by Keith Brown from
> http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
> would show you what account the application is running under.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | Lines: 78
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: 12.108.244.117
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet:165699
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Thanks for the response.
> |
> | I understand that, but I'm trying to create a directory on the local
> drive.
> | This isn't a mapped share. The drive is physically present on the web
> | server, and if that web server fails, the other system physically takes
> over
> | the drive (ie, a cluster). I've also added the local ASPNET account to
> the
> | NTFS permissions on the folder, and it still fails.
> |
> | - Chad
> |
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > I agree with Natty. The problem you are having is most likely caused
by
> | > having no right to access network resources. Willy address a similar
> | > problem before. See
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | >
> | > HTH,
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | Subject: System.IO.IOException: Cannot create a file when that file
> | > already exists.
> | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | Lines: 29
> | > |
> | > | Getting the following error on my production server whether the file
> | > exists
> | > | or not:
> | > |
> | > | "System.IO.IOException: Cannot create a file when that file already
> | > exists."
> | > |
> | > | Here's the code generating the error (seems to be happening when I
try
> | > | creating a directory)
> | > |
> | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | lblerror.Text = lblerror.Text & "Unable to build physical
> path.
> | "
> | > &
> | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | Else
> | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > |
> | > | This code runs fine on my development server (only the path is
> | > c:\blah\blah
> | > | instead of S). Also, my production server has failover cluser, and
> the
> | s
> | > | drive is the failover drive. I can't imagine that could be a
problem,
> | but
> | > | thought I would mention it.
> | > |
> | > | Asside from that, the only other thing I can think of is that the
> | > framework
> | > | version on my dev box says 1.1, and the one on my production server
> | says:
> | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
be
> an
> | > | issue (i've even tried as domain admin)
> | > |
> | > | I would appreciate any help on this, as I'm out of ideas, and can
find
> | no
> | > | other documentation on this.
> | > | - Chad
> | > |
> | > |
> | > |
> | >
> |
> |
> |
Chad, was the problem resolved? It seems that you installed both v1.03 and
v1.1 on the same web server. If so, it might be helpful to look at the
article "Compatibility Considerations and Version Changes" on
http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring your
web application to run V1.03 and V1.1 specifically to see how it works.

-Allen

Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com

-------
| From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
<j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
<exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
<RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
| Subject: Re: System.IO.IOException: Cannot create a file when that file
already exists.
| Date: Mon, 11 Aug 2003 01:16:22 -0400
| Lines: 141
|
|
| It doesn't work creating folders under the same directory as the web
| application... same issue.
|
| I'm going to try figuring out why that server is showing that it's running
| version 1.03 of the dotnet framework. It shows that v1.1 was installed.
|
| Thanks,
| Chad
|
| "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
| > Try creating a directory in your code under the folder where your web
| > application resides. Does it works? In addition, you may want to verify
| the
| > account your web application is running under. Please download tokedump
| > written by Keith Brown from
| > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx. It
| > would show you what account the application is running under.
| >
| > -Allen
| >
| > Disclaimer:
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| > Got .Net? http://www.gotdotnet.com
| >
| > -------
| > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
| > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
| > | Subject: Re: System.IO.IOException: Cannot create a file when that
file
| > already exists.
| > | Date: Thu, 7 Aug 2003 08:11:44 -0400
| > | Lines: 78
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 12.108.244.117
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:165699
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Thanks for the response.
| > |
| > | I understand that, but I'm trying to create a directory on the local
| > drive.
| > | This isn't a mapped share. The drive is physically present on the
web
| > | server, and if that web server fails, the other system physically
takes
| > over
| > | the drive (ie, a cluster). I've also added the local ASPNET account
to
| > the
| > | NTFS permissions on the folder, and it still fails.
| > |
| > | - Chad
| > |
| > |
| > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
| > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
| > | > I agree with Natty. The problem you are having is most likely caused
| by
| > | > having no right to access network resources. Willy address a similar
| > | > problem before. See
| > | >
| > |
| >
|
http://groups.google.com/groups?q=S...et&start=10&hl=
| > | >
en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
| > | >
| > | > HTH,
| > | > -Allen
| > | >
| > | > Disclaimer:
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | rights.
| > | > Got .Net? http://www.gotdotnet.com
| > | >
| > | > -------
| > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
| > | > | Subject: System.IO.IOException: Cannot create a file when that
file
| > | > already exists.
| > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
| > | > | Lines: 29
| > | > |
| > | > | Getting the following error on my production server whether the
file
| > | > exists
| > | > | or not:
| > | > |
| > | > | "System.IO.IOException: Cannot create a file when that file
already
| > | > exists."
| > | > |
| > | > | Here's the code generating the error (seems to be happening when I
| try
| > | > | creating a directory)
| > | > |
| > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
| > | > | lblerror.Text = lblerror.Text & "Unable to build physical
| > path.
| > | "
| > | > &
| > | > | txt_name.Text & " & Contact Dev Team.<BR>"
| > | > | Else
| > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
| > | > |
| > | > | This code runs fine on my development server (only the path is
| > | > c:\blah\blah
| > | > | instead of S). Also, my production server has failover cluser,
and
| > the
| > | s
| > | > | drive is the failover drive. I can't imagine that could be a
| problem,
| > | but
| > | > | thought I would mention it.
| > | > |
| > | > | Asside from that, the only other thing I can think of is that the
| > | > framework
| > | > | version on my dev box says 1.1, and the one on my production
server
| > | says:
| > | > | 1.0.37 - surely that's not the cause is it? Permissions shouldn't
| be
| > an
| > | > | issue (i've even tried as domain admin)
| > | > |
| > | > | I would appreciate any help on this, as I'm out of ideas, and can
| find
| > | no
| > | > | other documentation on this.
| > | > | - Chad
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
Allen,

Thanks for the followup. I actually got my program working late last night.
The problem was the framework version.

I tried simply configuring the web application to use version 1.1, but that
didn't help. I also tried uninstalling then reinstalling framework version
1.1, but that also didn't get IIS to start using version 1.1 by default. I
consequently uninstalled versions 1.1 *and* version 1.03, then only
reinstalled version 1.1 again, and this took care of the problem.

Thanks again for all the help everyone!

- Chad

"[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
news:hNsBh8sYDHA.2352@.cpmsftngxa06.phx.gbl...
> Chad, was the problem resolved? It seems that you installed both v1.03 and
> v1.1 on the same web server. If so, it might be helpful to look at the
> article "Compatibility Considerations and Version Changes" on
> http://www.gotdotnet.com/team/changeinfo/default.aspx. Try configuring
your
> web application to run V1.03 and V1.1 specifically to see how it works.
> -Allen
> Disclaimer:
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Got .Net? http://www.gotdotnet.com
> -------
> | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> <RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl>
> | Subject: Re: System.IO.IOException: Cannot create a file when that file
> already exists.
> | Date: Mon, 11 Aug 2003 01:16:22 -0400
> | Lines: 141
> |
> |
> | It doesn't work creating folders under the same directory as the web
> | application... same issue.
> |
> | I'm going to try figuring out why that server is showing that it's
running
> | version 1.03 of the dotnet framework. It shows that v1.1 was installed.
> |
> | Thanks,
> | Chad
> |
> | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | news:RT0i6ZXXDHA.2184@.cpmsftngxa06.phx.gbl...
> | > Try creating a directory in your code under the folder where your web
> | > application resides. Does it works? In addition, you may want to
verify
> | the
> | > account your web application is running under. Please download
tokedump
> | > written by Keith Brown from
> | > http://msdn.microsoft.com/msdnmag/i...ty/default.aspx.
It
> | > would show you what account the application is running under.
> | >
> | > -Allen
> | >
> | > Disclaimer:
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > Got .Net? http://www.gotdotnet.com
> | >
> | > -------
> | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | References: <uaJhi7FXDHA.1900@.TK2MSFTNGP10.phx.gbl>
> | > <j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl>
> | > | Subject: Re: System.IO.IOException: Cannot create a file when that
> file
> | > already exists.
> | > | Date: Thu, 7 Aug 2003 08:11:44 -0400
> | > | Lines: 78
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> | > | Message-ID: <exrIT0NXDHA.1204@.TK2MSFTNGP12.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | > | NNTP-Posting-Host: 12.108.244.117
> | > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
> | > | Xref: cpmsftngxa06.phx.gbl
> | microsoft.public.dotnet.framework.aspnet:165699
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | > |
> | > | Thanks for the response.
> | > |
> | > | I understand that, but I'm trying to create a directory on the local
> | > drive.
> | > | This isn't a mapped share. The drive is physically present on the
> web
> | > | server, and if that web server fails, the other system physically
> takes
> | > over
> | > | the drive (ie, a cluster). I've also added the local ASPNET account
> to
> | > the
> | > | NTFS permissions on the folder, and it still fails.
> | > |
> | > | - Chad
> | > |
> | > |
> | > | "[MSFT]Allen" <yweng@.online.microsoft.com> wrote in message
> | > | news:j1MRYHMXDHA.2108@.cpmsftngxa06.phx.gbl...
> | > | > I agree with Natty. The problem you are having is most likely
caused
> | by
> | > | > having no right to access network resources. Willy address a
similar
> | > | > problem before. See
> | > | >
> | > |
> | >
> |
http://groups.google.com/groups?q=S...et&start=10&hl=
> | > | >
> en&lr=&ie=UTF-8&oe=UTF-8&selm=OELVHLBNCHA.2460%40tkmsftngp04&rnum=20.
> | > | >
> | > | > HTH,
> | > | > -Allen
> | > | >
> | > | > Disclaimer:
> | > | > This posting is provided "AS IS" with no warranties, and confers
no
> | > | rights.
> | > | > Got .Net? http://www.gotdotnet.com
> | > | >
> | > | > -------
> | > | > | From: "Chad Crowder" <chad.crowder@.gis.leica-geosystems.com>
> | > | > | Subject: System.IO.IOException: Cannot create a file when that
> file
> | > | > already exists.
> | > | > | Date: Wed, 6 Aug 2003 17:08:27 -0400
> | > | > | Lines: 29
> | > | > |
> | > | > | Getting the following error on my production server whether the
> file
> | > | > exists
> | > | > | or not:
> | > | > |
> | > | > | "System.IO.IOException: Cannot create a file when that file
> already
> | > | > exists."
> | > | > |
> | > | > | Here's the code generating the error (seems to be happening when
I
> | try
> | > | > | creating a directory)
> | > | > |
> | > | > | If dirmgr.Exists("s:\blah\" & txt_name.Text) Then
> | > | > | lblerror.Text = lblerror.Text & "Unable to build
physical
> | > path.
> | > | "
> | > | > &
> | > | > | txt_name.Text & " & Contact Dev Team.<BR>"
> | > | > | Else
> | > | > | dirmgr.CreateDirectory("s:\blah\" & txt_name.Text)
> | > | > |
> | > | > | This code runs fine on my development server (only the path is
> | > | > c:\blah\blah
> | > | > | instead of S). Also, my production server has failover cluser,
> and
> | > the
> | > | s
> | > | > | drive is the failover drive. I can't imagine that could be a
> | problem,
> | > | but
> | > | > | thought I would mention it.
> | > | > |
> | > | > | Asside from that, the only other thing I can think of is that
the
> | > | > framework
> | > | > | version on my dev box says 1.1, and the one on my production
> server
> | > | says:
> | > | > | 1.0.37 - surely that's not the cause is it? Permissions
shouldn't
> | be
> | > an
> | > | > | issue (i've even tried as domain admin)
> | > | > |
> | > | > | I would appreciate any help on this, as I'm out of ideas, and
can
> | find
> | > | no
> | > | > | other documentation on this.
> | > | > | - Chad
> | > | > |
> | > | > |
> | > | > |
> | > | >
> | > |
> | > |
> | > |
> | >
> |
> |
> |

Monday, March 26, 2012

System.Net.Mail

This is some code for VB that is supposed to work in ASP. How come it
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username and
password.

'create the mail message
'Dim mail As New MailMessage()

'set the addresses
'mail.From = New MailAddress("me@dotnet.itags.org.mycompany.com")
'mail.To.Add(test1@dotnet.itags.org.testdomain.com)

'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."

'send the message
'Dim smtp As New SmtpClient("127.0.0.1")

'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an "authentication"
email to work.

I have 1.1 and 2.0 syntaxes.

http://sholliday.spaces.live.com/ 2/8/2006

While the code is in C#, you'll at least see the properties you need to set.

You need to find the
TestApp_2_0 . Program.cs file.

Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)

"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

This is some code for VB that is supposed to work in ASP. How come it
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username and
password.
>
>
'create the mail message
'Dim mail As New MailMessage()
>
'set the addresses
'mail.From = New MailAddress("me@.mycompany.com")
'mail.To.Add(test1@.testdomain.com)
>
'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."
>
'send the message
'Dim smtp As New SmtpClient("127.0.0.1")
>
'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)
>
>


I tried your link on two different computers and they both crash about 10
seconds after viewing the first page. Is there a problem with your link?

"sloan" <sloan@.ipass.netwrote in message
news:eQwZRS7yGHA.4496@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>
If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an "authentication"
email to work.
>
I have 1.1 and 2.0 syntaxes.
>
http://sholliday.spaces.live.com/ 2/8/2006
>
While the code is in C#, you'll at least see the properties you need to
set.
>
You need to find the
TestApp_2_0 . Program.cs file.
>
>
Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)
>
>
>
"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>This is some code for VB that is supposed to work in ASP. How come it
>doesn't seem to work in ASP?
>It is supposed to send mail to an SMTP server that requires a username
>and
>password.
>>
>>
>'create the mail message
>'Dim mail As New MailMessage()
>>
>'set the addresses
>'mail.From = New MailAddress("me@.mycompany.com")
>'mail.To.Add(test1@.testdomain.com)
>>
>'set the content
>'mail.Subject = "TEST TEST TEST This is an email"
>'mail.Body = "this is the body content of the email."
>>
>'send the message
>'Dim smtp As New SmtpClient("127.0.0.1")
>>
>'to authenticate we set the username and password properites on the
>SmtpClient
>'smtp.Credentials = New NetworkCredential("username", "secret")
>'smtp.Send(mail)
>>
>>


>
>


Use a browser besides IE.

I think microsoft sent an update out for IE.. and it crashes when it goes to
a spaces.msn.com/somebody type site.

They redid the look/feel of the msn spaces.

I get the same issue sometimes.

I thought it was just me, but apparently not.

"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:evdOsLFzGHA.4044@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

I tried your link on two different computers and they both crash about 10
seconds after viewing the first page. Is there a problem with your link?
>
>
>
>
"sloan" <sloan@.ipass.netwrote in message
news:eQwZRS7yGHA.4496@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by


If you work thru my sample project ... at the blog, you'll find the
different switches you need to experiment with to get an


"authentication"

Quote:

Originally Posted by

Quote:

Originally Posted by

email to work.

I have 1.1 and 2.0 syntaxes.

http://sholliday.spaces.live.com/ 2/8/2006

While the code is in C#, you'll at least see the properties you need to
set.

You need to find the
TestApp_2_0 . Program.cs file.

Here is what to find ... under the 2/8/2006 entry
You can download the code HERE. (Right-Click and "Save As" works best)

"AbraAbraCadabra" <nws@.gsw-inc.comwrote in message
news:%23W2kW$6yGHA.1292@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

This is some code for VB that is supposed to work in ASP. How come it
doesn't seem to work in ASP?
It is supposed to send mail to an SMTP server that requires a username
and
password.
>
>
'create the mail message
'Dim mail As New MailMessage()
>
'set the addresses
'mail.From = New MailAddress("me@.mycompany.com")
'mail.To.Add(test1@.testdomain.com)
>
'set the content
'mail.Subject = "TEST TEST TEST This is an email"
'mail.Body = "this is the body content of the email."
>
'send the message
'Dim smtp As New SmtpClient("127.0.0.1")
>
'to authenticate we set the username and password properites on the
SmtpClient
'smtp.Credentials = New NetworkCredential("username", "secret")
'smtp.Send(mail)
>
>



>
>

System.Net.Mail & sending emails with line breaks

Hi,

When a client sends an email via a web form (text entered in a asp:TextBox server control), the email received has no line breaks, and it is displayed in one line. This has bad impact on email readability... How can one overcome this probelm?

Thank you,

Alon

If you are sending mail text in simple text format then you have to use System.Environment.NewLine to move rest text in next line.

SmtpMail.SmtpServer = "1.0.0.127";
MailMessage mm = new MailMessage();
mm.From = "bill@.microsoft.com";
mm.To = "job@.apple.com";
mm.Subject = "";
mm.Body = "line 1" + System.Environment.NewLine + "line 2";


Hi,

Thank you for your reply.

I forgot to metion that the mail is sent in HTML format:

mailMessage.IsBodyHtml =true;

Am I supposed to parse the user's message (the text in the TextBox control), chck for CRLF (or is it \n) and replace it with System.Environment.NewLine? Isn't there some standard way to send the email, as i is in the text box (multiline text box. It looks like a text area)?

Thank you,

Alon


Here is the modified code for HTML formated body

mm.Body = "line 1" + "<br>" + "line 2";

Rest of the code will remain same.


But how can I know where line1 ends and line2 starts? All I have is a string I get form TextBox.Text. From this string I cannot deduce where did the user hit return - it's a "flat" string.

A word about he context of this: this web form is a "Contact Us" page. The TextBox is a multiline text box, which serves as a free text input field.

Thank you,

Alon


As what Firoz said, you have to use the "<br />"

You will use the following code to replace each line in your textbox to break

Replace(textbox1.text, vbCrLf,"<br />")

HTH
Regards


Oooops, now I understand. It works. I thank the both of you.

Alon

system.net.mail network host cache?

I need to change the name of the mail server for my .NET application. I changed it in web.config and on the .aspx page that sends the message. However, I still get an error message saying that the remote name could not be resolved, and the error message has the name of theold mail server. I have tried rebooting the server, but still get the same error.

Does .NET save configuration settings somewhere other than web.config? Is something getting cached? Other ideas?

Are you running VS debugger or testing on IIS server?

You can delete all files in cache.

Do you use only one config file?

If you have BLL and DAL, sometimes you have also config files here.


Visit this?site.
http://www.systemwebmail.com/

As Johan said, delete your temporary files, and build your web site again

Thanks


Thanks for the responses.

JohanNL, this site is on an IIS server. There is only one web.config file for the site. I did not implement BLL/DAL.

JohanNL and e_screw - this is probably a dumb question - when you say to delete cache/temp files, do you mean the ones in c:\windows\temp? Or what is the correct location?


You need to clear the ASP.NET temporary files

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

Thanks

Saturday, March 24, 2012

System.Net.Mail.SmtpException

My webserver does not have smtp on it but I'm still able to relay email to my email server with user name and password, my first question is that the dotnet is using an API that's built into server to relay?

Also email stopped working a day ago with error messageSyntax error, command unrecognized. The server response was: 5.1.0 Dropping connection due to an error on this server . Could this error be caused by the internal process dotnet uses to relay not working?

The 5.1.0 error is usually on the remote SMTP server and the error is propogated back to you. Does the server you relay to allow relays?

You're not relaying. System.Net.Mail simply sends the message to the defined SMTP server. Your error is a SMTP error, check the logs on the SMTP server to see what is happening, if you can. A 5.1.0 is a Sender Denied error, which most likely means you now need to use authentication. Checkwww.systemnetmail.com for help and samples.

Jeff


Still not getting this working getting, any help would be appreciated.

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Line 88: try
Line 89: {
Line 90: client.Send(message);
Line 91: Response.Redirect("RequestAccepted.aspx");
Line 92: }
Source File:d:\Inetpub\KPClient\ContactUS.aspx.cs Line:90

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1001874 System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431[WebException: Unable to connect to the remote server] System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +1447464 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +190 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +318 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +227 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316 System.Net.Mail.SmtpClient.GetConnection() +42 System.Net.Mail.SmtpClient.Send(MailMessage message) +1485


This turned out to be a bad router change that was not documented.

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Fed
eration.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!
Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.
So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
but to upload you must write an ASPX page that will accept file and save to
the folder on a server.
George.
"Amos Soma" <amos_j_soma@.yahoo.com> wrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...
>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
> webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/F
ederation.Zip",
> @."C:\Temp\Federation.Zip");
> 'Federation' is a virtual directory on the server I'm attempting to upload
> the file to. The URL is valid and the file I'm attempting to transfer
> exists. I keep getting 404 errors (not found). It's not clear to me
> exactly what cannot be found. If I attempt to download this exact file
> from the same exact URL using webClient.DownloadFile, it works fine!
> Thanks for the help - Amos.
>
Thus wrote George Ter-Saakov,

> You can not simply upload file on a server.
> Something should wait for that file at the server end.
> So url
> http://sdtpcal.someserver.com/Feder.../Federation.Zip to
> download file looks correct.
> but to upload you must write an ASPX page that will accept file and
> save to the folder on a server.
You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).
Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:

webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");

'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!

Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.

So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.

but to upload you must write an ASPX page that will accept file and save to
the folder on a server.

George.

"Amos Soma" <amos_j_soma@.yahoo.comwrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
>
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@."C:\Temp\Federation.Zip");
>
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me
exactly what cannot be found. If I attempt to download this exact file
from the same exact URL using webClient.DownloadFile, it works fine!
>
Thanks for the help - Amos.
>
>


Thus wrote George Ter-Saakov,

Quote:

Originally Posted by

You can not simply upload file on a server.
Something should wait for that file at the server end.
So url
http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
>
but to upload you must write an ASPX page that will accept file and
save to the folder on a server.


You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).

Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.

Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebClient.DownloadFile doesn't work with http attachments

Hi,
I have an aspx page at the web server that provides PDF documents for smart
client applications.
Here is the code in aspx page that defines content type:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
I tested the aspx page by using browser and it works just fine.
Now I need to receive that file by using the
System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
returns the following exception:
"Unable to read data from the transport connection: The connection was
closed."
I tested the DownloadFile method to open a direct pdf file like the
following statement:
(new
System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf
");
It works just fine.
How can I use System.Net.WebClient. DownloadFile to download http
attachments?
Any help would be apprecited,
AlanThe answer is in your question, but you may not recognize it.
An HTTP Request is for a single resource, identified by the URL of the
resource, or in the case of the WebClient, a URI plus a file descriptor. You
have an ASPX page that returns a file with a couple of special Response
Headers in it. Those Response Headers read:
Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
This header indicates that the client should prompt the client to make a
second request for the file descriptor specified (text.pdf), and that the
Content-Type of that file is binary.
So, what you have to do is read the Response Headers, and make a second
request for that file specified.
IETF RFC 1806 has a detailed explanation of this Response Header:
http://www.ietf.org/rfc/rfc1806.txt
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
A watched clock never boils.
"A.M-SG" <alanalan@.newsgroup.nospam> wrote in message
news:eY7l5Zu3FHA.1148@.tk2msftngp13.phx.gbl...
> Hi,
> I have an aspx page at the web server that provides PDF documents for
> smart
> client applications.
> Here is the code in aspx page that defines content type:
> Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
> "attachment;filename=test.pdf");
> I tested the aspx page by using browser and it works just fine.
> Now I need to receive that file by using the
> System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
> returns the following exception:
> "Unable to read data from the transport connection: The connection was
> closed."
> I tested the DownloadFile method to open a direct pdf file like the
> following statement:
> (new
> System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.p
df");
> It works just fine.
> How can I use System.Net.WebClient. DownloadFile to download http
> attachments?
> Any help would be apprecited,
> Alan
>

System.Net.WebClient.DownloadFile doesnt work with http attachments

Hi,

I have an aspx page at the web server that provides PDF documents for smart
client applications.

Here is the code in aspx page that defines content type:

Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");

I tested the aspx page by using browser and it works just fine.

Now I need to receive that file by using the
System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
returns the following exception:

"Unable to read data from the transport connection: The connection was
closed."

I tested the DownloadFile method to open a direct pdf file like the
following statement:

(new
System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf");

It works just fine.

How can I use System.Net.WebClient. DownloadFile to download http
attachments?

Any help would be apprecited,
AlanThe answer is in your question, but you may not recognize it.

An HTTP Request is for a single resource, identified by the URL of the
resource, or in the case of the WebClient, a URI plus a file descriptor. You
have an ASPX page that returns a file with a couple of special Response
Headers in it. Those Response Headers read:

Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");

This header indicates that the client should prompt the client to make a
second request for the file descriptor specified (text.pdf), and that the
Content-Type of that file is binary.

So, what you have to do is read the Response Headers, and make a second
request for that file specified.

IETF RFC 1806 has a detailed explanation of this Response Header:

http://www.ietf.org/rfc/rfc1806.txt

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"A.M-SG" <alanalan@.newsgroup.nospam> wrote in message
news:eY7l5Zu3FHA.1148@.tk2msftngp13.phx.gbl...
> Hi,
> I have an aspx page at the web server that provides PDF documents for
> smart
> client applications.
> Here is the code in aspx page that defines content type:
> Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
> "attachment;filename=test.pdf");
> I tested the aspx page by using browser and it works just fine.
> Now I need to receive that file by using the
> System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
> returns the following exception:
> "Unable to read data from the transport connection: The connection was
> closed."
> I tested the DownloadFile method to open a direct pdf file like the
> following statement:
> (new
> System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf");
> It works just fine.
> How can I use System.Net.WebClient. DownloadFile to download http
> attachments?
> Any help would be apprecited,
> Alan

System.Net.WebException and server committed a protocol violation

Hi there,

Does anyone knows what causes the System.Net.WebException and server committed a protocol violation and how do I debug it? Sometimes when I send the url request string to the web brower by using theHttpWebRequest andHttpWebResponseand it doesn't have any System.Net.WebException or server committed a protocol violation, but after a couple request sending, I get that error at theHttpWebResponse ,at first I thought because there are too many request sending at once, that's why it causes the System.Net.WebException and the server committed a protocol violation, but after a few minutes waiting and I re-send it again and still have the same error. Does anyone have the same problem that I have? This is the HTTPHandler Class and sending the request string by the url

I google some search and found some article saying that you can create a function to disable thewebRequest.KeepAlive = false;to solve that problem, but I got an error at 'HandlerLibrary.WebRequest(string)': no suitable method found to override, Can someone shows me the right way to fix this issue, thanks

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);

webRequest.KeepAlive = false;
return webRequest;
}