- Home /
No valid Cross Domain Policy with FTPWebRequest
Hi I am using this code to get a list of files on an FTP server which can't be done with WWW class. I have a cross domain xml file on my server and it works fine for the http stuff of downloading files using WWW class but not the FTPWebRequest stuff. I am not sure how to tell Unity to find crossdomain.xml for my FTPWebRequest calls?
Debug.Log("Attempting to Connect");
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://mysite.com/www/Viewer/Projects");
request.Credentials = new NetworkCredential("user", "password");
request.Method = "NLST";
Debug.Log("Getting Response");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Debug.Log("Getting the Stream");
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
while (!reader.EndOfStream)
{
string ProjectName = reader.ReadLine();
ProjectFolders.Add(ProjectName);
Debug.Log(ProjectName);
}
reader.Close();
response.Close();
Debug.Log("Reached End");
Don't you need to tell FTPWebRequest that it needs to access a crossdomain.xml?
Answer by code_warrior · Jan 02, 2015 at 06:48 PM
Hi cmkbim,
normally the crossdomain.xml file is placed in the root directory of your web space (e.g. www.example.com/crossdomain.xml). Your Browser or FTPWebrequest should then automatically find it.
Another thing you could try:
Just go to edit>project settings>editor> the change the default host url to your own host url, host url means your sever url. :-)
code_warrior