Click here to Skip to main content
15,890,557 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Unable to find asembly reference for agclr,system.silverlight,system.xml.core Pin
Abhinav S7-Jun-10 23:26
Abhinav S7-Jun-10 23:26 
QuestionLocalization in PRISM WPF application Pin
zlakob7-Jun-10 0:40
zlakob7-Jun-10 0:40 
AnswerRe: Localization in PRISM WPF application Pin
Michael Eber22-Jun-10 6:19
Michael Eber22-Jun-10 6:19 
QuestionConvert to upper case on editing the cell data in WPF datagrid Pin
kartheesh6-Jun-10 23:01
kartheesh6-Jun-10 23:01 
AnswerRe: Convert to upper case on editing the cell data in WPF datagrid Pin
#realJSOP7-Jun-10 2:40
mve#realJSOP7-Jun-10 2:40 
GeneralRe: Convert to upper case on editing the cell data in WPF datagrid Pin
kartheesh7-Jun-10 3:14
kartheesh7-Jun-10 3:14 
AnswerRe: Convert to upper case on editing the cell data in WPF datagrid Pin
Pete O'Hanlon8-Jun-10 12:38
mvePete O'Hanlon8-Jun-10 12:38 
QuestionHow do you express file paths on the Website server from a Web service? [WORKAROUND] Pin
fjparisIII6-Jun-10 12:35
fjparisIII6-Jun-10 12:35 
If I get this question answered, a lot of gaps in my understanding of Websites are going to be filled in, so hopefully someone will give me the answer.

I have a WCF-based Web service for my Silverlight Website application and the Web service DLL is located in /bin off of the root of the Website. It has many services correctly accessing a SQL Server database and sending email to the client, so I know that it is set up correctly.

Now, I have a bunch of JPEG files in /bin/ClientBin/SplashScreenPhotos. I would like to add another service that returns an ObservableCollection<string> of JPEG file names (just the file names, not the whole path) to my Silverlight application. Once the application has that, it knows how to display those JPEG files, because it's doing it now with a list of file names hard-coded in the Silverlight application (hard-coding things is bad).

My idea is to create a service that would look like this to populate the ObservableCollection:
[OperationContract]
public bool GetList(out ObservableCollection<string> list)
{
    list = new ObservableCollection<string>();
    string folder = ???;
    string[] files = Directory.GetFiles(folder, "*.jpg");
    foreach (string path in files)
    {
        string fileOnly = System.IO.Path.GetFileName(path);
        list.Add(fileOnly);
    }
    return true;
}

My question thus is, what do I substitute for the ??? This is basically a question of how the service navigates through the Website file system. I've been fooling with this for hours without getting anywhere. Using paths like /bin/ClientBin/SplashScreenPhotos does not work. I'm thinking that I'm probably off-base in using the .NET Directory class to begin with, but I don't know what I should be using.

[WORKAROUND added 2010-06-07]: I solved my problem through a fairly simple workaround. Instead of my service accessing my Website's file system directly (for all I know, something that is impossible), I used the FtpWebRequest class to do the job for me. The WebRequest.Method was WebRequestMethods.Ftp.ListDirectory, which returns a WebResponse object, from which you can create a StreamReader initialized with WebResponse.GetResponseStream(). I implemented the whole thing needed by the Web service through the following function, which the service calls:

ObservableCollection<string> GetFileNamesFromFtpDirectory(string remotePath)
{
    var result = new ObservableCollection<string>();
    Uri uri = new Uri(remotePath);
    WebRequest ftp = FtpWebRequest.Create(uri) as FtpWebRequest;
    ftp.Credentials = new NetworkCredential("xxxx", "yyyy");
    ftp.Method = WebRequestMethods.Ftp.ListDirectory;
    WebResponse response = null;
    try
    {
        response = ftp.GetResponse();
    }
    catch (Exception e)
    {
        // "The remote server returned an error: (530) Not logged in."
        string error = e.Message;
        return null;
    }
    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
        string line = reader.ReadLine();
        while (line != null)
        {
            result.Add(line);
            line = reader.ReadLine();
        }
    }
    return result;
}


"xxxx" and "yyyy" are top secret strings that provide my Website credentials. The remotePath input to the function is something like this:
"ftp://www.website.com/ClientBin/SplashScreenPhotos"


modified on Monday, June 7, 2010 4:29 PM

AnswerRe: How do you express file paths on the Website server from a Web service? Pin
fjparisIII7-Jun-10 10:01
fjparisIII7-Jun-10 10:01 
QuestionWPF - Navigation w/o click sound Pin
crystal91545-Jun-10 13:56
crystal91545-Jun-10 13:56 
QuestionVisual Studio 2010 WPF and ListBoxes Pin
RossouwDB2-Jun-10 22:02
RossouwDB2-Jun-10 22:02 
QuestionIs it possible to do a streaming upload to my server of audio recordings as they are being recorded by my Silverlight client-side application? Pin
Sandra McLeod2-Jun-10 8:39
Sandra McLeod2-Jun-10 8:39 
AnswerRe: Is it possible to do a streaming upload to my server of audio recordings as they are being recorded by my Silverlight client-side application? Pin
fred_8-Jun-10 10:17
fred_8-Jun-10 10:17 
QuestionPhotoshop like image editor with a drag and drop image gallery Pin
ikbegins1-Jun-10 23:37
ikbegins1-Jun-10 23:37 
AnswerRe: Photoshop like image editor with a drag and drop image gallery Pin
Abhinav S3-Jun-10 23:27
Abhinav S3-Jun-10 23:27 
AnswerRe: Photoshop like image editor with a drag and drop image gallery Pin
fjparisIII6-Jun-10 13:38
fjparisIII6-Jun-10 13:38 
GeneralRe: Photoshop like image editor with a drag and drop image gallery Pin
Mycroft Holmes6-Jun-10 15:02
professionalMycroft Holmes6-Jun-10 15:02 
GeneralRe: Photoshop like image editor with a drag and drop image gallery Pin
ikbegins7-Jun-10 21:50
ikbegins7-Jun-10 21:50 
GeneralRe: Photoshop like image editor with a drag and drop image gallery Pin
Mycroft Holmes7-Jun-10 22:19
professionalMycroft Holmes7-Jun-10 22:19 
GeneralRe: Photoshop like image editor with a drag and drop image gallery Pin
ikbegins9-Jun-10 21:37
ikbegins9-Jun-10 21:37 
QuestionSilverlight ---- Viewbox Control : How ? Pin
milestanley1-Jun-10 21:26
milestanley1-Jun-10 21:26 
AnswerRe: Silverlight ---- Viewbox Control : How ? Pin
Abhinav S1-Jun-10 21:47
Abhinav S1-Jun-10 21:47 
GeneralRe: Silverlight ---- Viewbox Control : How ? Pin
milestanley1-Jun-10 22:07
milestanley1-Jun-10 22:07 
AnswerRe: Silverlight ---- Viewbox Control : How ? Pin
Abhinav S1-Jun-10 23:11
Abhinav S1-Jun-10 23:11 
GeneralRe: Silverlight ---- Viewbox Control : How ? Pin
milestanley1-Jun-10 23:34
milestanley1-Jun-10 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.