Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Why do i get this error?

$
0
0

Visual Studio 2017 Community Cross Plattform App Project Xamarin:
I have granted full access to the local folders and also tried several code examples.
and still get the error message System.IO.FileNotFoundException: Could not find file "/D:\Temp\test.txt".
The file in the folder exists and the path is correct.

Does anybody know if i have to install an additonal package in Visual Studio that this works?

using System;
using System.IO;
using System.Net;
using System.Text;

namespace TestApp
{

public class WebRequestGetExample
{
public static void Main()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://8x.xxx.xx.xx3/files/test.txt");
request.Method = WebRequestMethods.Ftp.UploadFile;

        // This example assumes the FTP site uses anonymous logon.
        request.Credentials = new NetworkCredential("´root", "xxxx");

        // Copy the contents of the file to the request stream.
        StreamReader sourceStream = new StreamReader(@"D:\temp\test.txt");
        byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
        sourceStream.Close();
        request.ContentLength = fileContents.Length;

        Stream requestStream = request.GetRequestStream();
        requestStream.Write(fileContents, 0, fileContents.Length);
        requestStream.Close();

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

        response.Close();
    }
}

}

WebRequestGetExample.Main () [0x00033].
10-02 13:42:08.196 D/Mono ( 3241): Assembly Ref addref Mono.Android[0xad915d40] -> System[0xb06fc820]: 11
Error while resolving expression: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

System.IO.FileNotFoundException: Could not find file "/D:\Temp\test.txt".

10-02 13:46:51.378 D/Mono ( 3241): DllImport attempting to load: '/system/lib/liblog.so'.
10-02 13:46:51.378 D/Mono ( 3241): DllImport loaded library '/system/lib/liblog.so'.
10-02 13:46:51.378 D/Mono ( 3241): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
10-02 13:46:51.378 D/Mono ( 3241): Searching for '__android_log_print'.
10-02 13:46:51.378 D/Mono ( 3241): Probing '__android_log_print'.
10-02 13:46:51.378 D/Mono ( 3241): Found as '__android_log_print'.
10-02 13:46:51.384 I/MonoDroid( 3241): UNHANDLED EXCEPTION:
10-02 13:46:51.425 I/MonoDroid( 3241): System.IO.FileNotFoundException: Could not find file "/D:\temp\test.txt".
10-02 13:46:51.425 I/MonoDroid( 3241): File name: '/D:\temp\test.txt'
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x001b5] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00067] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at System.IO.StreamReader..ctor (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
10-02 13:46:51.425 I/MonoDroid( 3241): at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor ….


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>