Advertisement
Advertisement
| 01.05.2008 at 05:01PM PST, ID: 23061400 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 01.05.2008 at 05:31PM PST, ID: 20592103 |
| 01.05.2008 at 11:33PM PST, ID: 20593086 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: |
using System;
using System.IO;
using System.Text;
class CreateFile
{
public static void Main1()
{
string path = @"c:\B2B\Partner.txt";
try
{
// Delete the file if it exists.
if (File.Exists(path))
{
// Note that no lock is put on the
// file and the possibliity exists
// that another process could do
// something with it between
// the calls to Exists and Delete.
File.Delete(path);
}
// Create the file.
using (FileStream fs = File.Create(path))
{
Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.ToString());
}
}
}
|
| 01.06.2008 at 02:20AM PST, ID: 20593399 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: |
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class CreateFile
{
static void Main(string[] args)
{
string path = @"c:\B2B\Partner.txt";
try
{
// Delete the file if it exists.
if (File.Exists(path))
{
// Note that no lock is put on the
// file and the possibliity exists
// that another process could do
// something with it between
// the calls to Exists and Delete.
File.Delete(path);
}
// Create the file.
using (FileStream fs = File.Create(path))
{
Byte[] info = new UTF8Encoding(true).GetBytes(args[0]);
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.ToString());
}
}
}
}
|
| 01.06.2008 at 10:11AM PST, ID: 20594834 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: |
// The DLL/Class Library
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DLLFileFunctions
{
public class FileFunctions
{
public static bool WriteData(String path, String data, out String msg)
{
msg = String.Empty;
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
// Check to see if directory exist
msg = "Directory does not exist, create before calling this function";
return false;
}
// Create the file if it exist it will be deleted first
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
// Add some information to the file.
sw.Write(data);
}
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
return true;
}
public static bool GetData(String path, out string data)
{
// Check if the file exist
if (!File.Exists(path))
{
data = "File does not exist.";
return false;
}
// Get the data from the file.
using (StreamReader sr = new StreamReader(path))
{
data = sr.ReadToEnd();
}
return true;
}
}
}
===================================================================
// Test program
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
if (!FileFunctions.WriteData(@"C:\Temp\BBB.txt", "Data To Write", out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
String data = String.Empty;
if (!FileFunctions.GetData(@"C:\Temp\BBB.txt", out data))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.Read();
}
}
}
|
| 01.06.2008 at 11:42AM PST, ID: 20595270 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: |
//Console Application
// Test program
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
if (!FileFunctions.WriteData(@"C:\Temp\BBB.txt", "Data To Write", out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
String data = String.Empty;
if (!FileFunctions.GetData(@"C:\Temp\BBB.txt", out data))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.Read();
}
}
}
//DLL Code
// The DLL/Class Library
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DLLFileFunctions
{
public class FileFunctions
{
public static bool WriteData(String path, String data, out String msg)
{
msg = String.Empty;
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
// Check to see if directory exist
msg = "Directory does not exist, create before calling this function";
return false;
}
// Create the file if it exist it will be deleted first
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
// Add some information to the file.
sw.Write(data);
}
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
return true;
}
public static bool GetData(String path, out string data)
{
// Check if the file exist
if (!File.Exists(path))
{
data = "File does not exist.";
return false;
}
// Get the data from the file.
using (StreamReader sr = new StreamReader(path))
{
data = sr.ReadToEnd();
}
return true;
}
}
}
|
| 01.06.2008 at 12:39PM PST, ID: 20595503 |
| 01.06.2008 at 12:43PM PST, ID: 20595514 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: |
Test Program:
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
==================================================================
// DLL
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DLLFileFunctions
{
public class FileFunctions
{
public static bool WriteData(String path, String data, out String msg)
{
msg = String.Empty;
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
// Check to see if directory exist
msg = "Directory does not exist, create before calling this function";
return false;
}
// Create the file if it exist it will be deleted first
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
// Add some information to the file.
sw.Write(data);
}
}
return true;
}
public static bool GetData(String path, out string data)
{
// Check if the file exist
if (!File.Exists(path))
{
data = "File does not exist.";
return false;
}
// Get the data from the file.
using (StreamReader sr = new StreamReader(path))
{
data = sr.ReadToEnd();
}
return true;
}
}
}
|
| 01.06.2008 at 12:45PM PST, ID: 20595522 |
| 01.06.2008 at 01:25PM PST, ID: 20595676 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: |
// Test Program
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
if (Environment.GetCommandLineArgs().Length != 3)
{
// You need two arguments to be passed in and must be in
// the format of programName "/f:Path&Filename" "/d:The data to be save" or
// the format of programName "/d:The data to be save" "/f:Path&Filename"
Console.WriteLine("Invalid Number of Argument...");
Console.Read();
return;
}
else
{
String[] cmArgs = Environment.GetCommandLineArgs();
for (int idx = 1; idx < 3; idx++)
{
if (cmArgs[idx].Substring(0, 3) == "/p:")
{
// Get the file name to write to
path = cmArgs[idx].Substring(3);
}
else
{
if (cmArgs[idx].Substring(0, 3) == "/d:")
{
// get the data to write to the file
saveData = cmArgs[idx].Substring(3);
}
else
{
// Error in argument list
Console.WriteLine("Invalid Argument..." +
cmArgs[idx].Substring(0, 3));
Console.Read();
return;
}
}
}
}
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
|
| 01.06.2008 at 05:34PM PST, ID: 20596543 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: |
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
|
| 01.06.2008 at 07:23PM PST, ID: 20596937 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: |
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
|
| 01.06.2008 at 08:26PM PST, ID: 20597085 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: |
//TEST
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
while (saveData.Length > 0)
{
saveData = Console.ReadLine();
}
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
// DLL
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DLLFileFunctions
{
public class FileFunctions
{
public static bool WriteData(String path, String data, out String msg)
{
msg = String.Empty;
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
// Check to see if directory exist
msg = "Directory does not exist, create before calling this function";
return false;
}
// Create the file if it exist it will be deleted first
// using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
using (FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
// Add some information to the file.
sw.Write(data);
}
}
return true;
}
public static bool GetData(String path, out string data)
{
// Check if the file exist
if (!File.Exists(path))
{
data = "File does not exist.";
return false;
}
// Get the data from the file.
using (StreamReader sr = new StreamReader(path))
{
data = sr.ReadToEnd();
}
return true;
}
}
}
|
| 01.06.2008 at 08:54PM PST, ID: 20597141 |
| 01.06.2008 at 09:20PM PST, ID: 20597185 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: |
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
while (saveData.Length > 0)
{
saveData = Console.ReadLine();
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
|
| 01.07.2008 at 07:03AM PST, ID: 20599914 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
//Test Program
using System;
using System.Collections.Generic;
using System.Text;
using DLLFileFunctions; // This is the namespace name used in my DLL, Don't forget to add the reference to this project to the DLL.
namespace TestForDLL
{
class Program
{
static void Main(string[] args)
{
String msg = String.Empty;
String path = String.Empty;
String saveData = String.Empty;
String getData = String.Empty;
// Enter the path an name of the file to be created
Console.Write("Enter path and filename > ");
path = Console.ReadLine();
// Input data from the console to be stored in a file
Console.WriteLine("Enter Data > ");
saveData = Console.ReadLine();
Console.WriteLine("\n");
// Save the data to the file
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
while (saveData.Length > 0)
{
saveData = Console.ReadLine();
if (!FileFunctions.WriteData(path, saveData, out msg))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
}
// Read the data from the file.
if (!FileFunctions.GetData(path, out getData))
{
Console.WriteLine("Error: " + msg);
Console.Read();
}
Console.WriteLine(getData);
Console.Write("Press any key to teminate program");
Console.Read();
}
}
}
//DLL
// DLL
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace DLLFileFunctions
{
public class FileFunctions
{
public static bool WriteData(String path, String data, out String msg)
{
msg = String.Empty;
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
// Check to see if directory exist
msg = "Directory does not exist, create before calling this function";
return false;
}
// Create the file if it exist it will be deleted first
// using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
using (FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
// Add some information to the file.
sw.Write(data);
}
}
return true;
}
public static bool GetData(String path, out string data)
{
// Check if the file exist
if (!File.Exists(path))
{
data = "File does not exist.";
return false;
}
// Get the data from the file.
using (StreamReader sr = new StreamReader(path))
{
data = sr.ReadToEnd();
}
return true;
}
}
}
|