473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

get file names of files

Say I want to get the file name of C:\temp\something.xml and have that
put into a variable so I can encrypt the file and output it to
c:\temp\filename.enc. I have not found anything that solves this for
me.

I tired this

static void Main(string[] args)
{
string fileName = @("C:\","*.xml");
string path = @"C:\*.xml";
string result;

result = Path.GetFileName(fileName);
but that has to be static. Any help is appreciated.

Nov 16 '05 #1
4 3792
Not sure I understand your problem. What happens when you run your example
below? What do you mean by "but that has to be static"?

"HateBSOD" <h8*****@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Say I want to get the file name of C:\temp\something.xml and have that
put into a variable so I can encrypt the file and output it to
c:\temp\filename.enc. I have not found anything that solves this for
me.

I tired this

static void Main(string[] args)
{
string fileName = @("C:\","*.xml");
string path = @"C:\*.xml";
string result;

result = Path.GetFileName(fileName);
but that has to be static. Any help is appreciated.

Nov 16 '05 #2
HateBSOD,

The static GetFileName method on the Path class doesn't find files given
a wildcard string. Rather, it takes the file part of the path, and returns
that.

If you want to find files, I don't believe there is a managed code
method you can use. However, you can call the FindFirstFileEx function
through the P/Invoke layer.

Once you find your files, you can use the classes in the
System.Security.Cryptography namespace to encrypt the file, and the classes
in the System.IO namespace (specifically the FileStream class) to write the
new file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"HateBSOD" <h8*****@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Say I want to get the file name of C:\temp\something.xml and have that
put into a variable so I can encrypt the file and output it to
c:\temp\filename.enc. I have not found anything that solves this for
me.

I tired this

static void Main(string[] args)
{
string fileName = @("C:\","*.xml");
string path = @"C:\*.xml";
string result;

result = Path.GetFileName(fileName);
but that has to be static. Any help is appreciated.

Nov 16 '05 #3
hi
it is hard to get what you mean by " that has to be static " . would you
explain more what is the problem
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #4
I figured out that mess ended up being Directory.GetFiles to work, but
on the other hand I am using DES encryption and it works fine with
text, but not with a binary.

Do these have to use the binary writer or are these just for the keys,
anyways anyone have any ideas or samples on how to encrypt binary
files, with DES or AES.

DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);

Thanks.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Yasko | last post by:
Hi. Does anyone know if there's an equivalent of Perl's file::find module in Python? It traverses a directory. I've googled extensively and checked this newsgroup and can't find anything like it...
6
by: User | last post by:
Anyone have ideas which os command could be used to get the size of a file without actually opening it? My intention is to write a script that identifies duplicate files with different names. I...
1
by: santhosh_176 | last post by:
:I Created a Pocket PC application for iPAQ 5450. Every thing went fine even installer creation. I could run the setup and install it into the actual device and worked fine. The application enables...
8
by: Paul | last post by:
I have looked and looked for this info. All the I/O examples I've found either explicity use a file name or use the OpenFileDialog. When you drag a MS Word document over MS Word, it launches and...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: Jay | last post by:
What's the recommended way to change file/folder names within a project? I want to change the solution name from (say) sol1.sln to sol2.sln, and also everything else named sol1.* (eg sol1.suo,...
7
by: Adam | last post by:
Hello. I do most of my web dev work from a Mac (whose file system is case-insensitive.) I upload my web pages and other files onto a Unix-based host, which is case sensitive. When I look at the...
38
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
5
by: Steven D'Aprano | last post by:
After reading an earlier thread about opening and closing lots of files, I thought I'd do a little experiment. Suppose you have a whole lot of files, and you need to open each one, append a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.