문제

Having a silverlight application, intended to implement backup restore mechanism for the end user.

I have to get list of files in a specific directory resided in WebSite project via ria services.

By using which object I will be able to list files in specific directory of WebSite project.

Thanks for your attention.

도움이 되었습니까?

해결책 2

The answer is some kind of hack. I was inspired by the method that I have used to send client IP address to the service.

In default.aspx add this param to your silverlight object :

<param name="initParams" value="clientIP=<%=Request.UserHostAddress%>,serverPath=<%=Server.MapPath(".")%>" />

And in silverlight application :

    public string ClientIP=string.Empty;
    public string ServerPath = string.Empty;


    private void Application_Startup(object sender, StartupEventArgs e)
    {
        this.RootVisual = new MainPage();

        try
        {
            ClientIP = e.InitParams["clientIP"].ToString();
            ServerPath = e.InitParams["serverPath"].ToString();
        }
        catch 
        {
        }
    }

Consider that I sent client ip to the xap file for logging issues. You can omit it if you care.

and in Silverlight application call service method in this way :

 ser.GetFileList(((App)(App.Current)).ServerPath, FilesListReceived, null);

And the service side :

 public List<string> GetFileList(string baseDirectory)
 {
        var result = new List<BRFile>();

        var files =Directory.EnumerateFiles(  baseDirectory + "\\DBBackup" );

        ....
 }

Good Luck.

다른 팁

You can use the Directory class to enumerate files on the server. Adding a method to your domain service to return the list of file names to the Silverlight client should be fairly trivial after that.

http://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.100).aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top