Search Results

Search found 9 results on 1 pages for 'yeahumok'.

Page 1/1 | 1 

  • Using RegEx to replace invalid characters

    - by yeahumok
    Hello I have a directory with lots of folders, subfolder and all with files in them. The idea of my project is to recurse through the entire directory, gather up all the names of the files and replace invalid characters (invalid for a SharePoint migration). However, i'm completely unfamiliar with Regular Expressions. The characters i need to get rid in filenames are: ~, #, %, &, *, { } , \, /, :, <, ?, -, | and "" I want to replace these characters with a blank space. I was hoping to use a string.replace() method to look through all these file names and do the replacement. So far, the only code i've gotten to is the recursion. I was thinking of the recursion scanning the drive, fetching the names of these files and putting them in a List. Can anybody help me with how to find/replace invalid chars with RegEx with those specific characters?

    Read the article

  • Changing FileNames using RegEx and Recursion

    - by yeahumok
    Hello I'm trying to rename files that my program lists as having "illegal characters" for a SharePoint file importation. The illegal characters I am referring to are: ~ # % & * {} / \ | : < ? - "" What i'm trying to do is recurse through the drive, gather up a list of filenames and then through Regular Expressions, pick out file names from a List and try to replace the invalid characters in the actual filenames themselves. Anybody have any idea how to do this? So far i have this: (please remember, i'm a complete n00b to this stuff) class Program { static void Main(string[] args) { string[] files = Directory.GetFiles(@"C:\Documents and Settings\bob.smith\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); foreach (string file in files) { Console.Write(file + "\r\n"); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); string pattern = " *[\\~#%&*{}/:<>?|\"-]+ *"; string replacement = " "; Regex regEx = new Regex(pattern); string[] fileDrive = Directory.GetFiles(@"C:\Documents and Settings\bob.smith\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); StreamWriter sw = new StreamWriter(@"C:\Documents and Settings\bob.smith\Desktop\~Test Folder for [SharePoint] %testing\File_Renames.txt"); foreach(string fileNames in fileDrive) { string sanitized = regEx.Replace(fileNames, replacement); sw.Write(sanitized + "\r\n"); } sw.Close(); } } So what i need to figure out is how to recursively search for these invalid chars, replace them in the actual filename itself. Anybody have any ideas?

    Read the article

  • Drilling into a drive and changing folder names & document names

    - by yeahumok
    I have a drive on my computer that has folder--some of which have lots of folders w/in other folders and also contain files. I need to migrate these docs into sharepoint, however a LOT of these folders and files have invalid characters that will not allow me to migrate into sharepoint (i.e. " / \ &, etc.) Is there any way to write something in C# that basically removes these invalid characters from all folders and files? Please help!

    Read the article

  • Referencing the last row's data in Crystal Report

    - by yeahumok
    I have a report where the fields come from data pulled from a SQL server. I have a total field that i have added to the report...however i have an interesting conundrum--i was hoping someone had a formula i could use. Three of my columns do NOT need summation...however my project requirements are telling me instead to just pull the last number from the last row in the report and putting that in the total row. To better clarify: 1999 0.1% 0.2% 0.3% 2001 -2% 0.3% 3.4% Basically, in the total field, i'd be pulling the values from 2001 since it is the last report row. In my total row, i want to have -2%, 0.3% and 3.4% showing (since those are the last row's values). SO basically, i just want to pull the last report row's data (NOT total it). Anybody have a formula i can use for this?

    Read the article

  • Changing a datatype solely for the purpose of Excel Export in Crystal Reports

    - by yeahumok
    I have a report that has several numerical fields. To fill a project requirement, i had to use the following formula: if {DataTable1.No of Investments}>9999 then '*****' else toText({DataTable1.No of Investments},0) Basically, if the number fed in is bigger than 9999 it turns into * on the report. Now, when i try to export into excel, not only is the data type for all fields, strings...but the * show up versus numbers. I was wondering if there was a way to re-cast this back into a numerical value SOLELY for the purpose of excel exportation so that i'd be able to use excel formulas as well as see numbers instead of asterisks. I'd only be doing data-only excel exports. Any ideas?

    Read the article

  • Keeping last record with Grouping

    - by yeahumok
    Hi All I have a report that groups by Company names. I have 2 formula fields (for two of the columns) that pulls the last record from a field. However, i noticed that when i run my reports, it does not show the last record for every group (even though this total line is in the Group Footer). Is there anyway in the formula field, i can specify that the last record must show for every group in my report?

    Read the article

  • Why isn't my File.Move() working?

    - by yeahumok
    I'm not sure what exactly i'm doing wrong here...but i noticed that my File.Move() isn't renaming any files. Also, does anybody know how in my 2nd loop, i'd be able to populate my .txt file with a list of the path AND sanitized file name? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Text.RegularExpressions; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { //recurse through files. Let user press 'ok' to move onto next step string[] files = Directory.GetFiles(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); foreach (string file in files) { Console.Write(file + "\r\n"); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); //End section //Regex -- find invalid chars string pattern = " *[\\~#%&*{}/<>?|\"-]+ *"; string replacement = " "; Regex regEx = new Regex(pattern); string[] fileDrive = Directory.GetFiles(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing", "*.*", SearchOption.AllDirectories); List<string> filePath = new List<string>(); //clean out file -- remove the path name so file name only shows string result; foreach(string fileNames in fileDrive) { result = Path.GetFileName(fileNames); filePath.Add(result); } StreamWriter sw = new StreamWriter(@"C:\Documents and Settings\jane.doe\Desktop\~Test Folder for [SharePoint] %testing\File_Renames.txt"); //Sanitize and remove invalid chars foreach(string Files2 in filePath) { try { string sanitized = regEx.Replace(Files2, replacement); sw.Write(sanitized + "\r\n"); System.IO.File.Move(Files2, sanitized); System.IO.File.Delete(Files2); } catch (Exception ex) { Console.Write(ex); } } sw.Close(); } } } I'm VERY new to C# and trying to write an app that recurses through a specific drive, finds invalid characters (as specified in the RegEx pattern), removes them from the filename and then write a .txt file that has the path name and the corrected filename. Any ideas?

    Read the article

  • Recursively looping through a drive and replacing illegal characters

    - by yeahumok
    Hi I have to create an app that drills into a specific drive, reads all file names and replaces illegal SharePoint characters with underscores. The illegal characters I am referring to are: ~ # % & * {} / \ | : <> ? - "" Can someone provide either a link to code or code itself on how to do this? I am VERY new to C# and need all the help i can possibly get. I have researched code on recursively drilling through a drive but i am not sure how to put the character replace and the recursive looping together. Please help!

    Read the article

  • Recursively getting files in a directory with several sub-directories

    - by yeahumok
    Hello! I was wondering if anybody here could help me out as I'm still very new to C#. I have a drive with folders w/in folders w/in folders that all contain files. Is there a way to recursively loop through the files and gather up all of these file names into a .txt file? I'm not sure how to implement this into my Console app--so does anybody have any code that might help?

    Read the article

1