singrdk/base/Windows/mkpxecom/mkpxecom.cs

39 lines
1.1 KiB
C#
Raw Permalink Normal View History

2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
using System;
using System.IO;
namespace mkpxecom
{
/// <summary>
/// Summary description for mkpxecom.
/// </summary>
public class mkpxecom
{
static void Main(string[] args)
{
2008-11-17 18:29:00 -05:00
if (args.Length != 2) {
2008-03-05 09:52:00 -05:00
Console.WriteLine("Incorrect usage");
return;
}
int size = Convert.ToInt32(args[0]);
string fileName = args[1];
2008-11-17 18:29:00 -05:00
if (!File.Exists(fileName)) {
2008-03-05 09:52:00 -05:00
FileStream fs = new FileStream(fileName, FileMode.Create);
byte[] buffer = new byte[size];
fs.Write(buffer, 0, size);
}
2008-11-17 18:29:00 -05:00
else {
2008-03-05 09:52:00 -05:00
FileStream fs = new FileStream(fileName, FileMode.Open);
2008-11-17 18:29:00 -05:00
if (fs.Length != size) {
2008-03-05 09:52:00 -05:00
throw new Exception("File is of wrong size");
}
}
}
}
}