Monthly Archives: January 2015

Upload files to an FTP server in C#

The following FtpUploadFile method uploads a file to an FTP server. The to_uri parameter is a URI (Uniform Resource Identifier) that identifies the target file as in ftp://www.somewhere.com/test.txt. The other parameters are self-explanatory. // Use FTP to upload a file. … Continue reading

Posted in files, ftp, internet, web | Tagged , , , , , , , , , , , , , | Leave a comment

Upload text into a file on an FTP server in C#

The following FtpUploadString method uploads a text string into a file on an FTP server. The to_uri parameter is a URI (Uniform Resource Identifier) that identifies the target file as in ftp://www.somewhere.com/test.txt. The other parameters are self-explanatory. // Use FTP … Continue reading

Posted in files, ftp, internet, web | Tagged , , , , , , , , , , , , , | 4 Comments

Graph stock prices downloaded from the internet in C#

This example uses techniques described in other examples to graph stock prices downloaded from the internet. it’s based on these two examples: Get stock prices from the internet in C# Draw a labeled line graph that displays value tooltips in … Continue reading

Posted in finance, internet, mathematics, web | Tagged , , , , , , , , , , , , , | 2 Comments

Convert between long and short file names in C#

You can use the GetShortPathName API function to convert from long to short file names. The following code declares the API function. // Define GetShortPathName API function. [DllImport(“kernel32.dll”, CharSet = CharSet.Auto, SetLastError = true)] static extern uint GetShortPathName(string lpszLongPath, char[] … Continue reading

Posted in files, system | Tagged , , , , , , , , , | Leave a comment

Get stock prices from the internet in C#

There are many web sites that can return stock prices to a program. This program uses download.finance.yahoo.com. It builds a URL of the following form to get prices for MCI, DIS, COKE, and PEP: http://download.finance.yahoo.com/d/quotes.csv?s=MCI+DIS+COKE+PEP&f=sl1d1t1c1 The end of the URL, … Continue reading

Posted in finance, internet, mathematics, web | Tagged , , , , , , , , , , , , , | 19 Comments

Change program locale at runtime in C#

This example lets you change program locale at runtime so you can test localized programs. The example Test localized programs in C# explains how you can make a program select a specific locale when it starts so you can test … Continue reading

Posted in globalization, internationalization, localization | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Test localized programs in C#

The example Localize a program in C# explains how you can localize a program so it displays different user interfaces depending on the system’s locale. After you localize it, the program automatically selects the correct locale at runtime. Because it … Continue reading

Posted in globalization, internationalization, localization | Tagged , , , , , , , , , , , , , | 1 Comment

Localize a program in C#

Globalization is the process of building an application that can be used by users from different cultures. Localization is the process of customizing a globalized application for a specific culture. To localize an application: Build an application as usual. Place … Continue reading

Posted in globalization, internationalization, localization | Tagged , , , , , , , , , , , , , | 2 Comments

Select N random items from an array in C#

This example builds a generic extension method that lets you easily select N random objects from an array. For example, it lets you select 5 items from an array holding 10 names. Picking one random item from an array is … Continue reading

Posted in algorithms, arrays, mathematics, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Select random objects from an array in C#

This example builds a generic extension method that lets you easily select random objects from an array. The following code shows the extension method and the RandomTools class that defines it. public static class RandomTools { // The Random object … Continue reading

Posted in algorithms, arrays, mathematics, variables | Tagged , , , , , , , , , , , , | Leave a comment