Showing posts with label systemio. Show all posts
Showing posts with label systemio. Show all posts

Wednesday, March 28, 2012

system.IO

code snippet:-

sFile = x:\test\abcd.mdb

if (System.IO.File.Exists(sFile))
//do something
else
//do something else

my code is failing at Exists function. It does not find the file.

X:\ is a mapped drive. X drive has domain account permissions (like
domain\myLoginaccount). also I am runing my web application with default
security as annonymus user called domain\myLoginaccount

Why the Exsits function does not find the file. Am I missing any permissions
here...whats the best mthod to access the files from another machine thru
asp.net

thanks

cheers !I think there are 2 potential hurdles here:

1. does the account running the web page have privileges to access the
share? Be aware that as well as the IIS user and IIS impersonation, you also
have to consider which user the asp.net worker process is running as. This
is quite a complex subject and I'm afraid my knowledge is limited to the
general concept.

2. does the web app actually have the drive mapped? the web server will not
inherit mapped drives from a terminal session so unless you are mapping the
drive from the web app, I don't tihnk it will be there. I would suggest you
try again with a unc path.

Andy

"abcd" <abcd@.abcd.com> wrote in message
news:eXNa%23BpoFHA.3912@.TK2MSFTNGP10.phx.gbl...
> code snippet:-
> sFile = x:\test\abcd.mdb
> if (System.IO.File.Exists(sFile))
> //do something
> else
> //do something else
> my code is failing at Exists function. It does not find the file.
> X:\ is a mapped drive. X drive has domain account permissions (like
> domain\myLoginaccount). also I am runing my web application with default
> security as annonymus user called domain\myLoginaccount
> Why the Exsits function does not find the file. Am I missing any
> permissions here...whats the best mthod to access the files from another
> machine thru asp.net
> thanks
> cheers !
>

system.IO

code snippet:-
sFile = x:\test\abcd.mdb
if (System.IO.File.Exists(sFile))
//do something
else
//do something else
my code is failing at Exists function. It does not find the file.
X:\ is a mapped drive. X drive has domain account permissions (like
domain\myLoginaccount). also I am runing my web application with default
security as annonymus user called domain\myLoginaccount
Why the Exsits function does not find the file. Am I missing any permissions
here...whats the best mthod to access the files from another machine thru
asp.net
thanks
cheers !I think there are 2 potential hurdles here:
1. does the account running the web page have privileges to access the
share? Be aware that as well as the IIS user and IIS impersonation, you also
have to consider which user the asp.net worker process is running as. This
is quite a complex subject and I'm afraid my knowledge is limited to the
general concept.
2. does the web app actually have the drive mapped? the web server will not
inherit mapped drives from a terminal session so unless you are mapping the
drive from the web app, I don't tihnk it will be there. I would suggest you
try again with a unc path.
Andy
"abcd" <abcd@.abcd.com> wrote in message
news:eXNa%23BpoFHA.3912@.TK2MSFTNGP10.phx.gbl...
> code snippet:-
> sFile = x:\test\abcd.mdb
> if (System.IO.File.Exists(sFile))
> //do something
> else
> //do something else
> my code is failing at Exists function. It does not find the file.
> X:\ is a mapped drive. X drive has domain account permissions (like
> domain\myLoginaccount). also I am runing my web application with default
> security as annonymus user called domain\myLoginaccount
> Why the Exsits function does not find the file. Am I missing any
> permissions here...whats the best mthod to access the files from another
> machine thru asp.net
> thanks
> cheers !
>
>

system.Io function

hi, i want to know whether a file exists are not in a
particular directory.

how to write a function for it in asp.net using vbFile.Exists(path)

HTH

Thanks,

sswalia
MCAD, MCSD, OCA

"rahim" <rahim786@.rediffmail.com> wrote in message
news:059d01c3c523$20c4c700$a601280a@.phx.gbl...
> hi, i want to know whether a file exists are not in a
> particular directory.
> how to write a function for it in asp.net using vb
If System.IO.File.Exists("C:\somefile.txt") then
'it exists
End If

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz

"rahim" <rahim786@.rediffmail.com> wrote in message
news:059d01c3c523$20c4c700$a601280a@.phx.gbl...
> hi, i want to know whether a file exists are not in a
> particular directory.
> how to write a function for it in asp.net using vb

System.IO: best approach for clearing a DIR of all files except .CSV

hiya,
I have a DIR that should only accept .CSV files..I haven't found a way to
do this prorgramatically.

ATM, I:
1) obtain an array of all the files that contain a .CSV extension.
2) move these files to another dir.

I check to see if there are any NON-CSV files in the dir by the following:

<code>
If arrAllFiles.Length = arrCsvFiles.Length Then
'do nothing, as this DIR only contained CSV files.
Else
'delete ALL the files in this dir, as the CSV files have already been
moved.
'The remaining files are therefore, NON-CSV
End If
<\code
Is this a good approach?Or maybe there is a slicker way to achieve what I
am trying to do / maybe there are some utilities out there that already do
all the system.IO stuff?

All thoughts appreciated.

many thanks
yogi

--
Message posted via http://www.dotnetmonster.comYou could also loop through all the files, checkif they EndsWith(".csv") if
not, delete them.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

"chris yoker via DotNetMonster.com" <forum@.nospam.DotNetMonster.com> wrote
in message news:86e839cf6238492484f4c941524b48a4@.DotNetMonste r.com...
> hiya,
> I have a DIR that should only accept .CSV files..I haven't found a way to
> do this prorgramatically.
> ATM, I:
> 1) obtain an array of all the files that contain a .CSV extension.
> 2) move these files to another dir.
> I check to see if there are any NON-CSV files in the dir by the following:
> <code>
> If arrAllFiles.Length = arrCsvFiles.Length Then
> 'do nothing, as this DIR only contained CSV files.
> Else
> 'delete ALL the files in this dir, as the CSV files have already been
> moved.
> 'The remaining files are therefore, NON-CSV
> End If
> <\code>
> Is this a good approach?Or maybe there is a slicker way to achieve what I
> am trying to do / maybe there are some utilities out there that already do
> all the system.IO stuff?
> All thoughts appreciated.
> many thanks
> yogi
> --
> Message posted via http://www.dotnetmonster.com

System.IO?

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@dotnet.itags.org. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@dotnet.itags.org. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpanre:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


You are wrong.

If you wish to use System.IO, you must import it explicitly.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>


Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being

System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls

I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!

BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?

Thanks once again,

Regards,

Arpan

Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpan


Arpan,
If you do not see it in the using .. list (or "Import" in VB.NET) when you
create a class or web page, then you need to explicitly add it an ensure that
the project has a reference to the namespace assembly. If it isn't there, you
will find out about it very quickly!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Arpan" wrote:

Quote:

Originally Posted by

Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being
>
System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
>
I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!
>
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
>
Thanks once again,
>
Regards,
>
Arpan
>
>
Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


You are wrong.

If you wish to use System.IO, you must import it explicitly.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>


>
>


In ASP.NET 2.0, you can control which namespaces are
imported automatically by configuring them in web.config.

Any namespace you define in web.config will be automatically imported,
and you will not have to import it specifically.

See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
re:

Quote:

Originally Posted by

I hope the above 6 namespaces "do" get imported automatically by all ASP.NET pages.
If not, then please let me know.
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?


In ASP.NET 2.0, the default namespaces are defined in the default web.config, located in :
Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ CONFIG

Here they are :

<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>

You could add System.IO, so it's automatically imported, by adding :

<add namespace="System.IO" />

to the <namespacessection of web.config.

Of course, any other namespace you want to import automatically can also be added.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156710516.410124.90070@.m79g2000cwm.googlegro ups.com...
Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being

System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls

I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!

BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?

Thanks once again,

Regards,

Arpan

Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpan


"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

Please correct me if I am wrong.


You are wrong.
Thanks all of you for your helpful inputs.

Regards,

Arpan

Mark Rae wrote:

Quote:

Originally Posted by

"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>

Quote:

Originally Posted by

Please correct me if I am wrong.


>
You are wrong.


Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>If I am not wrong, System.IO is one of the seven namespaces
>that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>If I am not wrong, System.IO is one of the seven namespaces that get
>imported in all ASP.NET page automatically but in the following code:
>>
><%@. Import Namespace="System.IO" %>
><script runat="server">
> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>
> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>& "<br>"
> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>"<br>"
> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
> End Sub
></script>
><form runat="server">
><asp:Label ID="lblOutput" runat="server">
></form>
>>
>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>following error:
>>
>Type 'FileInfo' is not defined.
>>
>pointing to the very first line within the Page_Load sub (Dim
>ioFileInfo As New FileInfo...).
>>
>Why?
>>
>Please correct me if I am wrong.
>>
>Thanks,
>>
>Arpan
>>


>
>


Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the
compilation section to see the default imports (there are nine).

For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There
are eight listed there. The new one in 2.0 is System.Configuration.

Kevin Jones
re:

Quote:

Originally Posted by

Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).


Kevin,

don't you consider mscorlib to be one of them ?

<add assembly="mscorlib" />

Also, doesn't the vbc compiler automatically import Microsoft.VisualBasic ?

Also, isn't the list supplied in the default web.config's pages element accurate ?

<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>

Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?

See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Juan T. Llibre wrote:

Quote:

Originally Posted by

>re:

Quote:

Originally Posted by

>>If I am not wrong, System.IO is one of the seven namespaces
>>that get imported in all ASP.NET page automatically


>>
>You are wrong.
>>
>If you wish to use System.IO, you must import it explicitly.
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>aspnetfaq.com : http://www.aspnetfaq.com/
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en espaol : http://asp.net.do/foros/
>===================================
>"Arpan" <arpan_de@.hotmail.comwrote in message
>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>>If I am not wrong, System.IO is one of the seven namespaces that get
>>imported in all ASP.NET page automatically but in the following code:
>>>
>><%@. Import Namespace="System.IO" %>
>><script runat="server">
>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>
>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>& "<br>"
>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>"<br>"
>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>> End Sub
>></script>
>><form runat="server">
>><asp:Label ID="lblOutput" runat="server">
>></form>
>>>
>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>following error:
>>>
>>Type 'FileInfo' is not defined.
>>>
>>pointing to the very first line within the Page_Load sub (Dim
>>ioFileInfo As New FileInfo...).
>>>
>>Why?
>>>
>>Please correct me if I am wrong.
>>>
>>Thanks,
>>>
>>Arpan
>>>


>>
>>


Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).
>
For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
new one in 2.0 is System.Configuration.
>
Kevin Jones


don't you consider mscorlib to be one of them ?

Quote:

Originally Posted by

>
<add assembly="mscorlib" />


Oops, yep of course.

Quote:

Originally Posted by

Also, doesn't the vbc compiler automatically import


Microsoft.VisualBasic ?

Ah! I don't do VB, so I didn't look :)

Quote:

Originally Posted by

Also, isn't the list supplied in the default web.config's pages


element accurate ?

Quote:

Originally Posted by

>
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>


Yep, but I was listing the assemblies not the namespaces, which of
course I should have been.

Quote:

Originally Posted by

Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?
>
See :
>


http://msdn2.microsoft.com/en-us/li...collection.aspx

Quote:

Originally Posted by

and
>


http://msdn2.microsoft.com/en-us/li...gessection.aspx

Quote:

Originally Posted by

>


Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).


>
Kevin,
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>Juan T. Llibre wrote:

Quote:

Originally Posted by

>>re:
>>>If I am not wrong, System.IO is one of the seven namespaces
>>>that get imported in all ASP.NET page automatically
>>You are wrong.
>>>
>>If you wish to use System.IO, you must import it explicitly.
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>aspnetfaq.com : http://www.aspnetfaq.com/
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espaol : http://asp.net.do/foros/
>>===================================
>>"Arpan" <arpan_de@.hotmail.comwrote in message
>>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>>>If I am not wrong, System.IO is one of the seven namespaces that get
>>>imported in all ASP.NET page automatically but in the following code:
>>>>
>>><%@. Import Namespace="System.IO" %>
>>><script runat="server">
>>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>>
>>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>>& "<br>"
>>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>>"<br>"
>>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>>> End Sub
>>></script>
>>><form runat="server">
>>><asp:Label ID="lblOutput" runat="server">
>>></form>
>>>>
>>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>>following error:
>>>>
>>>Type 'FileInfo' is not defined.
>>>>
>>>pointing to the very first line within the Page_Load sub (Dim
>>>ioFileInfo As New FileInfo...).
>>>>
>>>Why?
>>>>
>>>Please correct me if I am wrong.
>>>>
>>>Thanks,
>>>>
>>>Arpan
>>>>
>>>


>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).
>>
>For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
>new one in 2.0 is System.Configuration.
>>
>Kevin Jones


>
>

System.IO: best approach for clearing a DIR of all files except .CSV

hiya,
I have a DIR that should only accept .CSV files..I haven't found a way to
do this prorgramatically.
ATM, I:
1) obtain an array of all the files that contain a .CSV extension.
2) move these files to another dir.
I check to see if there are any NON-CSV files in the dir by the following:
<code>
If arrAllFiles.Length = arrCsvFiles.Length Then
'do nothing, as this DIR only contained CSV files.
Else
'delete ALL the files in this dir, as the CSV files have already been
moved.
'The remaining files are therefore, NON-CSV
End If
<\code>
Is this a good approach?Or maybe there is a slicker way to achieve what I
am trying to do / maybe there are some utilities out there that already do
all the system.IO stuff?
All thoughts appreciated.
many thanks
yogi
Message posted via http://www.webservertalk.comYou could also loop through all the files, checkif they EndsWith(".csv") if
not, delete them.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"chris yoker via webservertalk.com" <forum@.nospam.webservertalk.com> wrote
in message news:86e839cf6238492484f4c941524b48a4@.Do
webservertalk.com...
> hiya,
> I have a DIR that should only accept .CSV files..I haven't found a way to
> do this prorgramatically.
> ATM, I:
> 1) obtain an array of all the files that contain a .CSV extension.
> 2) move these files to another dir.
> I check to see if there are any NON-CSV files in the dir by the following:
> <code>
> If arrAllFiles.Length = arrCsvFiles.Length Then
> 'do nothing, as this DIR only contained CSV files.
> Else
> 'delete ALL the files in this dir, as the CSV files have already been
> moved.
> 'The remaining files are therefore, NON-CSV
> End If
> <\code>
> Is this a good approach?Or maybe there is a slicker way to achieve what I
> am trying to do / maybe there are some utilities out there that already do
> all the system.IO stuff?
> All thoughts appreciated.
> many thanks
> yogi
> --
> Message posted via http://www.webservertalk.com