physical path in silverlight - c#

I need to get physical path in silverlight. I'm using WCF service, I created one folder called 'Myfolder'. So I need to get the path of myfolder Please help me.

Silverlight doesn't allow direct access to the file system. However you can take advantage of Isolated Storage to read and write files on the client side. Here is a tutorial for that.
If you need access to a folder in the web application that is hosting your Silverlight app, use your service. Once you are in your OperationContract method, or even if you leverage the WebClient to make an AJAX style request, you can access the file system on the server but remember that is a different machine than your Silverilght client with the exception of when you do development (or browse your app on the server).

Related

Is there a way to map a path from an external server?

Well, I've been working on my server with a method like the following:    
System.Web.HttpContext.Current.Server.MapPath("/path/something");
... and it's been working so far. Nevertheless, now I've encountered an issue. The thing is, I need to write a file that's located on an external server. Is there a method in C# to do this?
Server.mappath is designed to convert web based paths to local paths based on the location of the webroot, and is not strictly speaking relevant when trying to access external resources.
The only exception being when a remote file location is used as part of a websites file system. E.G. If your website has a folder in it called "/remotefiles/", and within IIS you have mapped this folder to a remote network path. MapPath would work as normal and you will retrieve a full UNC path.
If the server you want to access is on the same network as your web server but not referenced as part of your webroot, then you should look at directly referencing the location in question using a full UNC path. E.G. "\\ExternalServer\CDrive\SomeStuff\".
If the server is remotely accessed over a wider network, then you will need to look into another form of access.

Read files from client folder and upload to server - ASP.NET

What is the best way to get files from client folder (a folder that the client will choose the path) and upload to server?
Thanks.
You can't.
For privacy reasons, code from web sites running in a browser context is not allowed to enumerate files or directories on the client machine and send that information to a server. Imagine what would happen if it could!
You could possibly get around this limitation with some more complicated solution that includes a client side install (e.g. an ActiveX control) but this is simply not possible with ASP.NET alone.

Uploading files directly from C drive to Server

I want to upload files to server by giving file list in text file like
c:\file1.ext
c:\file2.ext
is this possible without using UploadFile control or form method in asp.net c# ?
Only if the server and client are on the same LAN or VPN, you can think of using this:
String source = #"c:\file1.ext";
String desctrination = #"\\SERVER\TRANSFERDATA\file1.ext";
File.Move(source, desctrination);
or
File.Copy(source, desctrination);
It's impossible to grab files from client's machine without using fileupload controls.
Http protocol doesn't allow to do that.
You could have file transfer on client's machine and it could send you those files, or you could have web service for uploading files, but you can't directly grab files from client's machine
If you want a quick and easy answer no, but there is no such thing as impossible!! you can do one of those options:
Creating WCF service and let client install it in his PC.
Using ActiveX.
in video link Below you can see that ASP.net application accessing point of sale device that plug to client PC, now if that application can access device, you can access the C drive..
Connect to POS device throw asp.net

Acessing files from a Server remotely

As the title says, I need to access files from a server remotely. After doing this, I need to show the files in a windows file/folder Dialog style.
I need this using Remoting.
It's not that simple since I have some problems:
I don't have access to the client UNC sharing;
I don't know where the \server\xpto is physically pointed;
The service at the server must use the physical path.
Also, the sharing must be enabled (not always is), I'd need to prompt username/password and I'd have the network path, not the physical.
So, it's like accessing a server in a data center using the client app.
I guess you can do it by a web application. Create a page on the server which can reach the local files on the server and displays a list of them on a grid. You can add some commands on the files as well. The page you created would act as a middleware to reflect the operations you want on the files.
hope it helps.

Serving Silverlight apps from the webserver

I am building my own web server and want to serve from it a Silverlight application. Is there anything else I have to do besides setting the mime type and pushing the application through the wire?
It probably makes no difference, but the web-server is in C# (the micro-edition).
No, silverlight is all run on the client, so unless you want to do some webservices or whatever, you needn't do anything other than set the mime-type.
It is really just like a separate file that you serve to the client, just like any image, script or css file.
If you are developing a single Silverlight application that you want to deliver then you need only serve the XAP.
However if you are not the application developer or you want to deliver multiple apps effeciently then your web server needs also to be able to deliver other files that may come along with these apps. For example the libraries may be be delivered as zip files and they may download external images and XML files. Still this is all likely to be simple static content you will not normally need to implement other services.
Note if you are hosting an app to be referenced by a HTML file served by some other server then you need to get your site to respond with appropriate XML when SL requests the clientaccesspolicy.xml file.

Categories