Click here to Skip to main content
15,906,081 members
Home / Discussions / C#
   

C#

 
PraiseRe: How can i read a xml file with Linq? c# Pin
bart10009-Jun-21 4:12
bart10009-Jun-21 4:12 
QuestionIs there any SQL Server on the cloud for free? Pin
Alex Dunlop8-Jun-21 8:15
Alex Dunlop8-Jun-21 8:15 
AnswerRe: Is there any SQL Server on the cloud for free? Pin
OriginalGriff8-Jun-21 10:45
mveOriginalGriff8-Jun-21 10:45 
GeneralRe: Is there any SQL Server on the cloud for free? Pin
Alex Dunlop9-Jun-21 4:16
Alex Dunlop9-Jun-21 4:16 
GeneralRe: Is there any SQL Server on the cloud for free? Pin
OriginalGriff9-Jun-21 4:26
mveOriginalGriff9-Jun-21 4:26 
QuestionHow to dynamically escape a character? Pin
Joseline Riker7-Jun-21 13:25
Joseline Riker7-Jun-21 13:25 
AnswerRe: How to dynamically escape a character? Pin
Dave Kreskowiak7-Jun-21 15:06
mveDave Kreskowiak7-Jun-21 15:06 
AnswerRe: How to dynamically escape a character? Pin
OriginalGriff7-Jun-21 19:50
mveOriginalGriff7-Jun-21 19:50 
To add to what Dave has said, that sounds like they are giving you the runaround: unless you are creating a batch or powershell file from your string then the '%' character has no special significance in either a command line to an application, or a filename. You can happily execute a C# program and hand it a single '%' as part of a file name:
C#
using System;

namespace OneOffConsole
    {
    class Program
        {
        static void Main(string[] args)
            {
            foreach (string s in args)
                {
                Console.WriteLine(s);
                }
            }
        }
    }
Microsoft Windows [Version 10.0.19043.985]
(c) Microsoft Corporation. All rights reserved.

C:\Users\PaulG>cd "D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug"

C:\Users\PaulG>D:

D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>oneoffconsole -variables -outputname "I am a filename 100%.mkv"
-variables
-outputname
I am a filename 100%.mkv

D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>dir >"x 100%.txt"

D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>type "x 100%.txt"
 Volume in drive D is GriffData
 Volume Serial Number is 4CA5-2F85

 Directory of D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug

08/06/2021  06:39    <DIR>          .
08/06/2021  06:39    <DIR>          ..
20/06/2019  17:39         4,079,616 itextsharp.dll
20/06/2019  17:39         3,180,097 itextsharp.xml
20/06/2019  17:39           169,984 itextsharp.xmlworker.dll
08/06/2021  06:35             4,608 OneOffConsole.exe
25/06/2019  06:47               189 OneOffConsole.exe.config
08/06/2021  06:35            19,968 OneOffConsole.pdb
08/06/2021  06:39                 0 x 100%.txt
               7 File(s)      7,454,462 bytes
               2 Dir(s)  805,619,617,792 bytes free

D:\Documents\AA Backed Up\My Projects\OneOffJobs\OneOffConsole\bin\Debug>

But that's worrying to me: because '%' isn't a special character in Windows, or C# - but it is in SQL, and only when passing strings to a database without using parameterised queries.
And that's very dangerous as it leaves an application wide open to something called "Sql Injection" which can destroy your entire database. Applications should always use Parameterized queries instead.

When you pass strings directly, you cause problems because SQL receives commands like:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
SQL
DROP TABLE MyTable;
A perfectly valid "delete the table" command
SQL
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

I'd suggest that you ask the developers why the '%' character is causing problems within a well-formed and quoted filename, and ask to see the code that it affects.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

AnswerRe: How to dynamically escape a character? Pin
Richard MacCutchan7-Jun-21 21:14
mveRichard MacCutchan7-Jun-21 21:14 
AnswerRe: How to dynamically escape a character? Pin
Eddy Vluggen9-Jun-21 9:49
professionalEddy Vluggen9-Jun-21 9:49 
QuestionINotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
BillWoodruff7-Jun-21 11:35
professionalBillWoodruff7-Jun-21 11:35 
AnswerRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
Eddy Vluggen8-Jun-21 4:21
professionalEddy Vluggen8-Jun-21 4:21 
GeneralRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
BillWoodruff8-Jun-21 10:48
professionalBillWoodruff8-Jun-21 10:48 
GeneralRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
Eddy Vluggen9-Jun-21 6:19
professionalEddy Vluggen9-Jun-21 6:19 
AnswerRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
Gary R. Wheeler13-Jun-21 8:26
Gary R. Wheeler13-Jun-21 8:26 
GeneralRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
BillWoodruff14-Jun-21 4:53
professionalBillWoodruff14-Jun-21 4:53 
GeneralRe: INotifyPropertyChanged/Changing: more useful in WPF compared to WinForms ? Pin
Gary R. Wheeler14-Jun-21 5:05
Gary R. Wheeler14-Jun-21 5:05 
QuestionUpdated an application that uses DDE. Specific requirements. Pin
ptmaker7-Jun-21 10:52
ptmaker7-Jun-21 10:52 
AnswerRe: Updated an application that uses DDE. Specific requirements. Pin
Mycroft Holmes7-Jun-21 12:10
professionalMycroft Holmes7-Jun-21 12:10 
GeneralRe: Updated an application that uses DDE. Specific requirements. Pin
ptmaker8-Jun-21 3:19
ptmaker8-Jun-21 3:19 
QuestionRe: Updated an application that uses DDE. Specific requirements. Pin
Eddy Vluggen9-Jun-21 6:24
professionalEddy Vluggen9-Jun-21 6:24 
QuestionControlled replay of recorded data Pin
Chuck8446-Jun-21 9:47
Chuck8446-Jun-21 9:47 
AnswerRe: Controlled replay of recorded data Pin
Gerry Schmitz6-Jun-21 16:43
mveGerry Schmitz6-Jun-21 16:43 
GeneralRe: Controlled replay of recorded data Pin
Chuck8446-Jun-21 19:13
Chuck8446-Jun-21 19:13 
GeneralRe: Controlled replay of recorded data Pin
Dave Kreskowiak7-Jun-21 4:21
mveDave Kreskowiak7-Jun-21 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.