Skip to content

Commit 85f4f1d

Browse files
authored
Remove empty sections (#6126)
* remove empty sections * added missing ; * feedback + vb * feedback
1 parent 845c0ba commit 85f4f1d

File tree

6 files changed

+458
-390
lines changed

6 files changed

+458
-390
lines changed
Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,76 @@
11
---
2-
title: "How to: Download Files with FTP"
3-
ms.date: "03/30/2017"
2+
title: "How to: Download files with FTP"
3+
description: "This article shows a sample of how to download a file from an FTP server."
4+
ms.date: "06/26/2018"
5+
dev_langs:
6+
- "csharp"
7+
- "vb"
48
ms.assetid: 892548b8-954a-4f6a-9bca-2ae620c3700f
5-
author: "mcleblanc"
6-
ms.author: "markl"
7-
manager: "markl"
89
---
9-
# How to: Download Files with FTP
10-
This sample shows how to download a file from an FTP server.
11-
12-
## Example
13-
14-
```csharp
15-
using System;
16-
using System.IO;
17-
using System.Net;
18-
using System.Text;
19-
20-
namespace Examples.System.Net
21-
{
22-
public class WebRequestGetExample
23-
{
24-
public static void Main ()
25-
{
26-
// Get the object used to communicate with the server.
27-
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
28-
request.Method = WebRequestMethods.Ftp.DownloadFile;
29-
30-
// This example assumes the FTP site uses anonymous logon.
31-
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
32-
33-
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
34-
35-
Stream responseStream = response.GetResponseStream();
36-
StreamReader reader = new StreamReader(responseStream);
37-
Console.WriteLine(reader.ReadToEnd());
38-
39-
Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
40-
41-
reader.Close();
42-
response.Close();
43-
}
44-
}
45-
}
46-
```
47-
48-
## Compiling the Code
49-
This example requires:
50-
51-
- References to the **System.Net** namespace.
52-
53-
## Robust Programming
54-
55-
## .NET Framework Security
10+
# How to: Download files with FTP
11+
12+
This sample shows how to download a file from an FTP server.
13+
14+
## Example
15+
16+
```csharp
17+
using System;
18+
using System.IO;
19+
using System.Net;
20+
21+
namespace Examples.System.Net
22+
{
23+
public class WebRequestGetExample
24+
{
25+
public static void Main ()
26+
{
27+
// Get the object used to communicate with the server.
28+
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
29+
request.Method = WebRequestMethods.Ftp.DownloadFile;
30+
31+
// This example assumes the FTP site uses anonymous logon.
32+
request.Credentials = new NetworkCredential("anonymous","janeDoe@contoso.com");
33+
34+
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
35+
36+
Stream responseStream = response.GetResponseStream();
37+
StreamReader reader = new StreamReader(responseStream);
38+
Console.WriteLine(reader.ReadToEnd());
39+
40+
Console.WriteLine($"Download Complete, status {response.StatusDescription}");
41+
42+
reader.Close();
43+
response.Close();
44+
}
45+
}
46+
}
47+
```
48+
49+
```vb
50+
Imports System.IO
51+
Imports System.Net
52+
53+
Namespace Examples.System.Net
54+
Public Module WebRequestGetExample
55+
Public Sub Main()
56+
' Get the object used to communicate with the server.
57+
Dim request As FtpWebRequest = CType(WebRequest.Create("ftp://www.contoso.com/test.htm"), FtpWebRequest)
58+
request.Method = WebRequestMethods.Ftp.DownloadFile
59+
60+
' This example assumes the FTP site uses anonymous logon.
61+
request.Credentials = New NetworkCredential("anonymous", "janeDoe@contoso.com")
62+
63+
Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
64+
65+
Dim responseStream As Stream = response.GetResponseStream()
66+
Dim reader As StreamReader = New StreamReader(responseStream)
67+
Console.WriteLine(reader.ReadToEnd())
68+
69+
Console.WriteLine($"Download Complete, status {response.StatusDescription}")
70+
71+
reader.Close()
72+
response.Close()
73+
End Sub
74+
End Module
75+
End Namespace
76+
```
Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,76 @@
11
---
2-
title: "How to: List Directory Contents with FTP"
3-
ms.date: "03/30/2017"
2+
title: "How to: List directory contents with FTP"
3+
description: "This article shows a sample of how to list the directory contents of an FTP server."
4+
ms.date: "06/26/2018"
5+
dev_langs:
6+
- "csharp"
7+
- "vb"
48
ms.assetid: 130c64c9-7b7f-4672-9b3b-d946bd2616c5
5-
author: "mcleblanc"
6-
ms.author: "markl"
7-
manager: "markl"
89
---
9-
# How to: List Directory Contents with FTP
10-
This sample shows how to list the directory contents of an FTP server.
11-
12-
## Example
13-
14-
```csharp
15-
using System;
16-
using System.IO;
17-
using System.Net;
18-
using System.Text;
19-
20-
namespace Examples.System.Net
21-
{
22-
public class WebRequestGetExample
23-
{
24-
public static void Main ()
25-
{
26-
// Get the object used to communicate with the server.
27-
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
28-
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
29-
30-
// This example assumes the FTP site uses anonymous logon.
31-
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
32-
33-
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
34-
35-
Stream responseStream = response.GetResponseStream();
36-
StreamReader reader = new StreamReader(responseStream);
37-
Console.WriteLine(reader.ReadToEnd());
38-
39-
Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
40-
41-
reader.Close();
42-
response.Close();
43-
}
44-
}
45-
}
46-
```
47-
48-
## Compiling the Code
49-
This example requires:
50-
51-
- References to the **System.Net** namespace.
52-
53-
## Robust Programming
54-
55-
## .NET Framework Security
10+
# How to: List directory contents with FTP
11+
12+
This sample shows how to list the directory contents of an FTP server.
13+
14+
## Example
15+
16+
```csharp
17+
using System;
18+
using System.IO;
19+
using System.Net;
20+
21+
namespace Examples.System.Net
22+
{
23+
public class WebRequestGetExample
24+
{
25+
public static void Main ()
26+
{
27+
// Get the object used to communicate with the server.
28+
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
29+
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
30+
31+
// This example assumes the FTP site uses anonymous logon.
32+
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
33+
34+
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
35+
36+
Stream responseStream = response.GetResponseStream();
37+
StreamReader reader = new StreamReader(responseStream);
38+
Console.WriteLine(reader.ReadToEnd());
39+
40+
Console.WriteLine($"Directory List Complete, status {response.StatusDescription}");
41+
42+
reader.Close();
43+
response.Close();
44+
}
45+
}
46+
}
47+
```
48+
49+
```vb
50+
Imports System.IO
51+
Imports System.Net
52+
53+
Namespace Examples.System.Net
54+
Public Module WebRequestGetExample
55+
Public Sub Main()
56+
' Get the object used to communicate with the server.
57+
Dim request As FtpWebRequest = CType(WebRequest.Create("ftp://www.contoso.com/"), FtpWebRequest)
58+
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
59+
60+
' This example assumes the FTP site uses anonymous logon.
61+
request.Credentials = New NetworkCredential("anonymous", "janeDoe@contoso.com")
62+
63+
Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
64+
65+
Dim responseStream As Stream = response.GetResponseStream()
66+
Dim reader As StreamReader = New StreamReader(responseStream)
67+
Console.WriteLine(reader.ReadToEnd())
68+
69+
Console.WriteLine($"Directory List Complete, status {response.StatusDescription}")
70+
71+
reader.Close()
72+
response.Close()
73+
End Sub
74+
End Module
75+
End Namespace
76+
```
Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
---
2-
title: "How to: Upload Files with FTP"
3-
ms.date: "03/30/2017"
2+
title: "How to: Upload files with FTP"
3+
description: "This article shows a sample of how to upload a file to an FTP server."
4+
ms.date: "06/26/2018"
5+
dev_langs:
6+
- "csharp"
7+
- "vb"
48
ms.assetid: e40f17c5-dd12-4c62-9dbf-00ab491382dc
5-
author: "mcleblanc"
6-
ms.author: "markl"
7-
manager: "markl"
89
---
9-
# How to: Upload Files with FTP
10-
This sample shows how to upload a file to an FTP server.
11-
12-
## Example
13-
14-
```csharp
15-
using System;
16-
using System.IO;
17-
using System.Net;
18-
using System.Text;
19-
20-
namespace Examples.System.Net
21-
{
22-
public class WebRequestGetExample
23-
{
24-
public static void Main ()
25-
{
26-
// Get the object used to communicate with the server.
10+
# How to: Upload files with FTP
11+
12+
This sample shows how to upload a file to an FTP server.
13+
14+
## Example
15+
16+
```csharp
17+
using System;
18+
using System.IO;
19+
using System.Net;
20+
using System.Text;
21+
22+
namespace Examples.System.Net
23+
{
24+
public class WebRequestGetExample
25+
{
26+
public static void Main ()
27+
{
28+
// Get the object used to communicate with the server.
2729
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
2830
request.Method = WebRequestMethods.Ftp.UploadFile;
2931

30-
// This example assumes the FTP site uses anonymous logon.
32+
// This example assumes the FTP site uses anonymous logon.
3133
request.Credentials = new NetworkCredential("anonymous", "janeDoe@contoso.com");
3234

33-
// Copy the contents of the file to the request stream.
35+
// Copy the contents of the file to the request stream.
3436
byte[] fileContents;
3537
using (StreamReader sourceStream = new StreamReader("testfile.txt"))
3638
{
3739
fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
3840
}
39-
41+
4042
request.ContentLength = fileContents.Length;
4143

4244
using (Stream requestStream = request.GetRequestStream())
@@ -46,18 +48,45 @@ namespace Examples.System.Net
4648

4749
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
4850
{
49-
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
51+
Console.WriteLine($"Upload File Complete, status {response.StatusDescription}");
5052
}
51-
}
52-
}
53-
}
54-
```
55-
56-
## Compiling the Code
57-
This example requires:
58-
59-
- References to the **System.Net** namespace.
60-
61-
## Robust Programming
62-
63-
## .NET Framework Security
53+
}
54+
}
55+
}
56+
```
57+
58+
```vb
59+
Imports System.IO
60+
Imports System.Net
61+
Imports System.Text
62+
63+
Namespace Examples.System.Net
64+
Public Module WebRequestGetExample
65+
Public Sub Main()
66+
' Get the object used to communicate with the server.
67+
Dim request As FtpWebRequest = CType(WebRequest.Create("ftp://www.contoso.com/test.htm"), FtpWebRequest)
68+
request.Method = WebRequestMethods.Ftp.UploadFile
69+
70+
' This example assumes the FTP site uses anonymous logon.
71+
request.Credentials = New NetworkCredential("anonymous", "janeDoe@contoso.com")
72+
73+
' Copy the contents of the file to the request stream.
74+
Dim fileContents As Byte()
75+
76+
Using sourceStream As StreamReader = New StreamReader("testfile.txt")
77+
fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
78+
End Using
79+
80+
request.ContentLength = fileContents.Length
81+
82+
Using requestStream As Stream = request.GetRequestStream()
83+
requestStream.Write(fileContents, 0, fileContents.Length)
84+
End Using
85+
86+
Using response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
87+
Console.WriteLine($"Upload File Complete, status {response.StatusDescription}")
88+
End Using
89+
End Sub
90+
End Module
91+
End Namespace
92+
```

0 commit comments

Comments
 (0)