Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to find a way to force illegal characters into a filename. Specifically ':' and '/'
We receive regular automated updates by email. These emails always contain illegal characters in the subject. We currently manually save off these emails for processing as a text file with the subject as the file name. This process works but is tedious.
I wrote a VBA script for saving the files and am working on a small C# application that processes these files locally before sending them of to our server.
The Outlook script simply replaces the illegal characters with a tag before saving:
sTemp = Replace(sTemp, "/", "{FS}")
sTemp = Replace(sTemp, ":", "{CO}")
I need to either find a method to save the files as-is from in the VBA script or change the tags back to the illegal characters when I'm processing locally.
The majority of the team is running Windows 7 x64, using Outlook 2008/10.
The best solution seems to be simply don't. I'm going to rework how we handle these messages rather than try to force this behavior.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am brand-new in C# and I wanna do that in C#.
Can you show me the way :)
Enter a remote machine hostname
get list folder names in C directory from the remote machine
select folder names from the list
delete the selected folders
show a message about the process (deleted or not)
Is that too hard? Thank you for your help in advance and sory for my bad English :(
Remote and local file system access in C# (.NET) works the same way. Try for example the following.
var directory = new System.IO.DirectoryInfo("\\server\path\remote\C");
var files = directory.GetFiles();
foreach(var f in files) f.Delete();
For remote drives, for example drive C, the path will be like: \server\c$\folderUnderC (note the dollar sign).
A broad question, here are a few general answers.
Enter a remote machine hostname
Set up a GUI for that (WinForms or whatever you like)
get list folder names in C directory from the remote machine
Look into remote directory services, especially Samba / SMB setup and access for Windows. This question will be usefull.
select folder names from the list
With the appriopiate GUI elements (a TreeView maybe), easily possible.
delete the selected folders
Issue a File.Delete() command for the appropiate path, see link above.
show a message about the process (deleted or not)
Wrap above command in a try-catch, then call MessageBox.Show() or whatever GUI elements you want for that.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I check if a file that is in a directory is a CSV file without checking its extension?
If the file extension is not a mandatory for your program design, but only format of the file (csv in your case), the only valid way to check if a given file is either "ok" for you or not, is simply to check your data structure after you populated it from the file.
The basic flow in gross may look like this:
1) Select file
2) Read the file
a) Exception happens somewhere = non valid CSV formatted file
b) All is ok
3) Validate datastructure(s) populated from the file
a) Some mandatory fields are not initialized = non valid CSV file
b) All is ok
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am writing simple program that will assist me to configure and sort out my files.I want the algorithm to search for matching string or text that the user inputs in the search box like windows search index , Google,or any other search engines.I doesn't have to be complex,just simple.you can show me by example or direct me to the appropriate resource.
https://support.microsoft.com/sv-se/kb/303974
Has some information that will get you going.
Edit: string[] files = Directory.GetFiles("C:\\", "*.dll");
This line will search through all files in c:\ for a file thats ending with .dll
Now you want it to search through all files that starts with something then youd have to run "yourstring*". In your example case, you only remember the starting "tes". Directory.GetFiles("C:\\", "tes*"); This line will search for a file starting with the filename "tes"
You can also use Directory.GetDirectories("C:\\"); to get all directories in c:\ and if you want then, loop through those directories with the same method to find all the subdirectories, then search for your file in all of those directories.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm having an issue in saving an rtf file, I'm saving it in a subfolder in "MyDocuments" the strange this is that i also save a .bin file and some other stuff and it doesn't causes any exeption, i'am pc admin so why does it happen?
string docs = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Monitor\\Immobili\\";`
richTextBox1.SaveFile(docs+code);
code is also another string
An UnauthorizedAccessException means one of 3 things:
The caller does not have the required permission.
Path is a directory.
Path specified a read-only file.
Check for last two reasons. I think you are not adding filename after path. Add breakpoints and check if richTextBox1.SaveFile(docs+code); is getting the complete path to the file instead of just folder path.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I`m using C# and I need to read something after EOF. Is it possible by using C#? How?
Thanks.
You cant. EOF means end of file, there's nothing actually in the file after that.
You may as well ask how you can get ten gallons of oil from a four-gallon drum. Once it's empty, there's no more to be had.
Since you're talking C# hence Windows (and based on your comment and data located behind the end of file pointer), it's possible that they may be referring to "DOS mode" text files, which are (or used to be, I haven't investigated recently) terminated by the CTRL-Z character.
From the earliest days of the PC revolution, where CP/M used integral numbers of disk blocks to store a file and only stored the number of disk blocks rather than the number of bytes, CTRL-Z was used to indicate end of file if the file wasn't an exact multiple of the disk block size.
If that's the case, it's probably best just to open the file as a binary file, then read up to the first CTRL-Z character (code point 26) - everything beyond that could be considered data beyond EOF if it's truly a text file of that format.