File name parsing issue with space c# - filenames

i am trying to merge two wave file using sox.exe.
when i am specifying small path then it is working but when i am giving big path with space in it then i am getting no error but no file is getting generated. i got a tips from this url
C# - Easiest way to parse filename with spaces eg. "C:\Test\File with spaces.txt"
but the above one did not work.
here i am giving few code that how my code look like
-m C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\in.wav
C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\capture.wav
C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\_20140506020037.wav
C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\sox.exe
and the above path as follows

Put all your path between ""
-m "C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\in.wav"
"C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\capture.wav"
"C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\_20140506020037.wav"

There's no code in your question But according to my experiences use this method for pathes including space:
string filename01 = "\"C:\Users\tridip.BBAKOLKATA\Documents\Visual Studio 2010\Projects\CSRAssistant\CSRAssistant\bin\Debug\VoiceRecords\capture.wav\""

Related

How do i set working directory in sql developer in code

I'm using sql developer.
I want to run some scripts.
I don't want to have to include the folder name in the call to each script.
But I also want to use a variable to include the directory to look in (the working directory).
I can do this but i am having trouble with folder names with spaces (this is in windows).
Can anyone help me work out how to do this without having to rename my folder to remove spaces?
define dir="c:\Users\xx\Google Drive\Analytics\Recruitment\NSL\2. Data Understanding\Code"
#&dir\cb_nsl_impairments.sql;
Returns error
SP2-0310: Unable to open file: "c:\Users\xx\Google.sql"
Oops. Solved it.
Just needed double quotes around the script call:
#"&dir\cb_nsl_impairments.sql"

What SQL argument have I got wrong?

Background: I have both SQL2008 and SQL2012 installed on my machine. This has resulted in only having the studio management for 2012 running, and any amount of trying wont let me add the studio for 2008.
Problem: Now I have backup that for verification reasons need to be restored on the 2008 instance without the 2012 management studio to avoid contamination, so I am trying to run the restore directly from the command prompt. I have let the 2012 studio make the actual command for me, and am now trying to put that into the prompt, but it won't run; and no amount of reading makes me see the invalid argument. I realize I am probably missing something elemental, but please have a look at it anyway.
The command that I am trying to run is:
C:\Program Files\Microsoft SQL Server\100\Tools\Binn>SqlCmd -E -S SQL2008 "RESTORE DATABASE Basename FROM DISK = N'D:\Folder\Backup.BAK' WITH FILE = 1, MOVE N'Base_Data' TO N'C:\Folder\Base.mdf', MOVE N'Base_1_Data' TO N'C:\Folder\Base_1.ndf', MOVE N'Base_2_Data' TO N'C:\Folder\Base_2.ndf', MOVE N'Base_Log' TO N'C:\Folder\Base_3.LDF', NOUNLOAD, STATS = 5"
And the response is a quick: Unexpected argument. Enter '-?' for help.
I don't see how -E or -S could be wrong, and the server is correct 2008 instance. I have tried it without the MOVEs to see if there could be something there, but it gave the same result.
So could someone please swing a 2 by 4 my way letting me know what I am doing wrong? Thank you
Maybe like this?
C:\Program Files\Microsoft SQL Server\100\Tools\Binn>SqlCmd -E -S SQL2008 -Q "RESTORE DATABASE Basename FROM DISK = N'D:\Folder\Backup.BAK' WITH FILE = 1, MOVE N'Base_Data' TO N'C:\Folder\Base.mdf', MOVE N'Base_1_Data' TO N'C:\Folder\Base_1.ndf', MOVE N'Base_2_Data' TO N'C:\Folder\Base_2.ndf', MOVE N'Base_Log' TO N'C:\Folder\Base_3.LDF', NOUNLOAD, STATS = 5"
It seems like the most common issue with this problem is copying and pasting from some other source, as mentioned in the comments in the other answer. My problem was copying and pasting from this article:
http://www.howtogeek.com/50295/backup-your-sql-server-database-from-the-command-line/
To fix this, try typing your command in manually so you know the exact value of every character. Usually the problem characters are double quotes, but they can also be single quotes, and my problem was in fact the dash character being U-2014, the "EN DASH". Even the spaces could potentially be nonblocking spaces i suppose.

Copy the content of an appxmainfest file to another using Pre-build command

I've been trying to get this re-build command working for a Windows 8 Project in Visual Studio 2012.
if "$(ConfigurationName)"==ReleaseOEM copy "$(ProjectDir)PackageOEM.appxmainfest" "$(ProjectDir)Package.appxmainfest" copy "$(ProjectDir)StoreManifestOEM.xml" "$(ProjectDir)StoreManifest.xml"
The xml file StoreManifest.xml is copied every time I do a rebuild; however the Package.appxmainfest is never changed.
What have I done wrong?
This worked in a test project ...
if "$(ConfigurationName)"=="Debug" copy "$(ProjectDir)Package.appxmanifest" "$(ProjectDir)Package2.appxmainfest"
The only real difference is I added quotes around Debug. It does not copy the file without the quotes. According to MSDN, you need to separate commands by line breaks. Yours should probably look something like ...
if "$(ConfigurationName)"=="ReleaseOEM" copy "$(ProjectDir)PackageOEM.appxmainfest" "$(ProjectDir)Package.appxmainfest"
if "$(ConfigurationName)"=="ReleaseOEM" copy "$(ProjectDir)StoreManifestOEM.xml" "$(ProjectDir)StoreManifest.xml"

Why won't MSBuild build a project with a dot in the name?

The Story So Far
I've got a nice solution with a desktop application project, a few library projects, and a couple of development tools projects (also desktop applications). At the moment, my build server outputs all of the code into one OutputPath. So we end up with
drop-x.y.z\
Company.MainApplication.exe <-- main application
Company.MainApplicationCore.dll <-- libraries
Helper.exe <-- developer tools
Grapher.exe
Parser.exe
... <-- the rest of the output
But, we're growing up and people outside of our team want access to our tools. So I want to organize the output. I decided that what we would want is a different OutputPath per executable project
drop-x.y.z\
Company.MainApplication\
Company.MainApplication.exe <-- main application
Company.MainApplicationCore.dll <-- libraries
... <-- application specific output
Helper\
Helper.exe <-- developer tools
... <-- tool specific output
Grapher\
Grapher.exe
...
Parser\
Parser.exe
...
What I Did
I found this simple command. I like it because it retains all the Solution working-dir context that makes msbuild a pain.
msbuild /target:<ProjectName>
For example, from my solution root as a working directory, I would call
PS> msbuild /target:Helper /property:OutputPath="$pwd\out\Helper"
I'm testing this from PowerShell, so that $pwd resolves to the full path to my working directory, or the Solution root in this case. I get the output I desire.
However, when I run this command
PS> msbuild /target:Company.MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
I get the following error output (there's no more information, I ran with /verbosity:diagnostic)
The target "Company.MainApplication" does not exist in the project.
What I Need
The command fails on any project with a dot or dots in the name. I tried with many combinations of working directories and properties. I tried several ways of escaping the property values. I also tried running the command from a <Task> in a targets file.
I need to know either
A) How to fix this command to work property
B) How to achieve the same output with minimal friction
Try using an underscore as an escape character for the dot in the target parameter, e.g.
msbuild /target:Company_MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
Specify the target after the -target: switch in the format :. If the project name contains any of the characters %, $, #, ;, ., (, ), or ', replace them with an _ in the specified target name.
https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe?view=vs-2019
Dan Nolan's answer and comments are correct. Just want to supplement the Microsoft documentation.
The /targets: switch is to identify a <Target to run in the project file. You need to supply your .csproj file as a an argument that is not prefixed by a /xx option marker.
You might also want to work based on the .sln file. In that case, you still dont specify the project in the .sln to build in this manner. I'll leave you to search up the correct syntax in case that's what you end up doing.

Automatically locating a file

By default AutoCAD installs a text based file called acad2010.lsp at the set location below
Dim FILE_NAME As String = "C:\Program Files\AutoCAD 2010\Support\acad2010.lsp"
However it my be that the user/ administrator/ or third party has changed the location of this file. Is it possible to then locate it using the following
Dim FILE_NAME As String = "C:\*\acad2010.lsp"
In other words search the entire c:\ drive for file acad2010.lsp?
If this doesn't work can you please let me know what would?
You could search for it with an FSO. It's not going to be fast however you do it but this is the fastest way I can think of.
http://www.microbion.co.uk/developers/fso.htm should give you a rough idea of how it's done.
Your solution will not work. Is not possible to locate it using *. (BTW is possible in ms-builds scripts). The only way of doing it is:
1- Create a FindFile function (check for example
http://xlvba.3.forumer.com/index.php?showtopic=125)
2- Use it to locate the exact path of the file. (It could be really time
consuming)
3- From this point your code is the same...
Unfortunately, you can't use wildcards in a filepath. You have two options:
Prompt the user for the file location using the "Open File" dialog. The code to do this varies based on which Office product you are using. In Excel, you would use the Application.FindFile method (more info here).
Write your own function to search the filesystem for the file. Microsoft provides an example here.
If that file is used by internal functions of the application, the installer will have recorded a registry key for the file's location.
Open regedit.exe and search for the file name and path.
You can read a registry entry using this VBA one-liner:
CreateObject("WScript.Shell").RegRead(strRegPath)
You may need a terminating backslash on the key address, but that's a safe and simple registry access method. More details on the MSDN site:
https://msdn.microsoft.com/en-us/library/x05fawxd%28v=vs.84%29.aspx