Hello there!

I was tired of having to edit my hosts manually, so I just started a small app that will open a nice user interface to it for me.

Most of the code is done. It opens the hosts, edits, saves, has cut, copy, paste, undo and redo functions. But my questions isn't related about that.

The questions are: I'm using a custom icon that I've downloaded from deviantArt. The .ico file is 344Kb larger. When I use it on the form, it is like the system copies it into the exe file. There is some way to do this but saving a bit of space? Also, the main window icon is separated from this one, so if I re-reference it, the program size is twice as big. The latest compiled assembly has 715Kb, which I think is too large for a small app. It will become even bigger because I have 2 forms and don't want to waste space with icons.

Another thing: everytime the user save the hosts file, it'll create an backup named hostsddMMyyyyhhmmss , where the ddMMyyyyhhmmss are day, month, year, hour, minute, second, respectively. I want to 'filter' them and show them inside a ListView control, so user can select one to restore. How can I filter the files named just like hostsddMMyyyyhhmmss ?

Thanks guys, that's all for now.

Edited 5 Years Ago by RenanLazarotto: n/a

The .ico file is 344Kb larger

That's not a Windows Icon File. Not quite sure but X Windows system has icons of that size. If you want a Windows ico file with a few Kb, try to convert file. If you don't have a suitable application, try open source GIMP.

I want to 'filter' them and show them inside a ListView control

Filter when you read file names from the disk? Use file mask hosts* and file the file name is longer than 5 chars, add it to listview. Or check that the name is valid hostsddMMyyyyhhmmss.

HTH

Thanks for the icon tip, I'll solve that later.

But how can I validade the filename? my code is this, by far:

string[] arquivos = Directory.GetFiles(@"C:\WINDOWS\system32\drivers\etc", "hosts*");

but I don't want to only see if the filename follow the 'hosts*' pattern, I want to check if its name is 'hostsddmmyyyyhhmmss'.

How can I archieve that? I read somewhere about a regex or something, this is what I need?

Edited 5 Years Ago by RenanLazarotto: n/a

Regex would work great for that. But really - there shouldn't be any other files starting with 'host' in that folder so it may be overkill.

The fact isn't about the hosts file, is because I want to only show files with 'ddmmyyyyhhmmss' pattern on its name.

Furthermore, I decided to backup the files at another place, where the app is running. So, technically, it'll only have the files I want and its much more easy to manage by myself.

I'll take a look into Regex anyway, might be useful later. I'll keep this thread open, because I'll post my code here as soon as I finish it.

This question has already been answered. Start a new discussion instead.