Click here to Skip to main content
15,903,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: Read n lines from file Pin
AFell231-Jan-19 6:24
AFell231-Jan-19 6:24 
QuestionTimer is get slowed after some time Pin
Mohamed Fahad26-Jan-19 1:01
Mohamed Fahad26-Jan-19 1:01 
AnswerRe: Timer is get slowed after some time Pin
OriginalGriff26-Jan-19 4:11
mveOriginalGriff26-Jan-19 4:11 
AnswerRe: Timer is get slowed after some time Pin
jschell26-Jan-19 7:00
jschell26-Jan-19 7:00 
AnswerRe: Timer is get slowed after some time Pin
Gerry Schmitz26-Jan-19 8:35
mveGerry Schmitz26-Jan-19 8:35 
AnswerRe: Timer is get slowed after some time Pin
Eddy Vluggen26-Jan-19 8:56
professionalEddy Vluggen26-Jan-19 8:56 
QuestionHow to read a xml file with WPF and unkown amount of data Pin
Member 1413010725-Jan-19 8:57
Member 1413010725-Jan-19 8:57 
AnswerRe: How to read a xml file with WPF and unkown amount of data Pin
Eddy Vluggen26-Jan-19 0:10
professionalEddy Vluggen26-Jan-19 0:10 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Member 1413010726-Jan-19 5:21
Member 1413010726-Jan-19 5:21 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Eddy Vluggen26-Jan-19 8:46
professionalEddy Vluggen26-Jan-19 8:46 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Member 1413010726-Jan-19 8:51
Member 1413010726-Jan-19 8:51 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Eddy Vluggen26-Jan-19 8:55
professionalEddy Vluggen26-Jan-19 8:55 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Member 1413010726-Jan-19 9:02
Member 1413010726-Jan-19 9:02 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Eddy Vluggen26-Jan-19 9:13
professionalEddy Vluggen26-Jan-19 9:13 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Member 1413010726-Jan-19 9:21
Member 1413010726-Jan-19 9:21 
AnswerRe: How to read a xml file with WPF and unkown amount of data Pin
Gerry Schmitz26-Jan-19 8:52
mveGerry Schmitz26-Jan-19 8:52 
GeneralRe: How to read a xml file with WPF and unkown amount of data Pin
Member 1413010726-Jan-19 12:22
Member 1413010726-Jan-19 12:22 
Questionc# Pin
Member 1412841524-Jan-19 0:36
Member 1412841524-Jan-19 0:36 
AnswerRe: c# Pin
Richard MacCutchan24-Jan-19 1:03
mveRichard MacCutchan24-Jan-19 1:03 
AnswerRe: c# Pin
Maciej Los24-Jan-19 2:45
mveMaciej Los24-Jan-19 2:45 
Questionpassing a file in to an Core 2.1 WebApi method Pin
Simon_Whale23-Jan-19 10:18
Simon_Whale23-Jan-19 10:18 
AnswerRe: passing a file in to an Core 2.1 WebApi method Pin
Richard Deeming23-Jan-19 11:31
mveRichard Deeming23-Jan-19 11:31 
Something like this should work:
C#
public static async Task UploadFile(HttpClient client, string url, string filePath, string contentType, CancellationToken cancellationToken)
{
    // Argument validation omitted...
    
    using (var fileStream = File.OpenRead(filePath))
    {
        var file = new StreamContent(fileStream);
        file.Headers.ContentType = MediaTypeHeaderValue.Parse(mimeType);
        file.Headers.ContentLength = fileStream.Length;
        
        var content = new MultipartFormDataContent();
        content.Add(file, "file", Path.GetFileName(filePath));
        
        using (var response = await client.PostAsync(url, content, cancellationToken).ConfigureAwait(false))
        {
            response.EnsureSuccessStatusCode();
        }
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: passing a file in to an Core 2.1 WebApi method Pin
Simon_Whale2-Feb-19 23:22
Simon_Whale2-Feb-19 23:22 
QuestionWhat is wrong with this code? Pin
nuno6921-Jan-19 9:42
nuno6921-Jan-19 9:42 
AnswerRe: What is wrong with this code? Pin
Eddy Vluggen21-Jan-19 10:56
professionalEddy Vluggen21-Jan-19 10:56 

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.