Hi xenophon,
Does the things in our former messages help you resolve the problem? If
there're anything else we can help, please feel free to post here. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 64214682
| References: <
[email protected]>
<#
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 04 Nov 2005 03:25:52 GMT
| Subject: Re: Protection Level Problem with DirectoryInfo
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 77
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:136031
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi xenophon,
|
| As Bruce has mentioned, the problem you ecountered is a compile time
error.
| The DirectoryInfo class has no default constructor and we need to provide
| the directory's path in the DirectoryInfo class's constructor rather than
| in GetFiles function.
| The GetFiles function's string parameter is used to represent file name
| pattern. For example:
|
| private void Page_Load(object sender, System.EventArgs e)
| {
| System.IO.DirectoryInfo fff = new DirectoryInfo(Server.MapPath("."));
| System.IO.FileInfo[] ppp = fff.GetFiles("*.aspx");
|
| DataGrid1.DataSource = ppp;
| DataGrid1.DataBind();
| }
|
| If there're any other questions on this, please feel free to post here.
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
| --------------------
| | From: "Bruce Barker" <
[email protected]>
| | References: <
[email protected]>
| | Subject: Re: Protection Level Problem with DirectoryInfo
| | Date: Thu, 3 Nov 2005 09:22:51 -0800
| | Lines: 47
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <#
[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: rdcsd1.safeco.com 12.144.134.2
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet:135863
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | if you read the documentation, you will see that DirectoryInfo does not
| have
| | an empty constructor and that GetFiles wants a file pattern match, not
a
| | directory name. try:
| |
| | System.IO.DirectoryInfo fff = new
| | System.IO.DirectoryInfo(Request.MapPath(".") );
| | System.IO.FileInfo[] ppp = fff.GetFiles();
| |
| | -- bruce (sqlwork.com)
| |
| |
| |
| | | | >
| | > This following innocuous code:
| | >
| | >
| | > System.IO.DirectoryInfo fff = new System.IO.DirectoryInfo();
| | > System.IO.FileInfo[] ppp = fff.GetFiles( Request.MapPath(".") );
| | > for( int ccc=0 ; ccc < ppp.Length ; ccc++ )
| | > {
| | > System.Web.HttpResponse.Response.Write(
| | > "<a href=\"" + Request.MapPath(".") + "/" +
| | > HttpUtility.HtmlEncode(ppp[ccc].Name) + "\">link</a>" );
| | > }
| | >
| | >
| | >
| | >
| | >
| | > Leads to this error:
| | >
| | > System.IO.DirectoryInfo.DirectoryInfo() is inaccessible due to its
| | > protection level
| | >
| | > How can I get around that? I want to simply enumerate files in a
| | > directory and put them in a DataList of <a> tags for UI clicking. I
| | > have stripped out the DataList-binding code in the example and reduced
| | > it to Response.Write statements.
| | >
| | >
| | > Thanks.
| | >
| | >
| |
| |
| |
|
|