Asp.net with c# file upload from excel using sql server 08 [closed] - sql

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 7 years ago.
Improve this question
Exception Details: System.Web.HttpException:
'c:/users/agaabhis/documents/visual studio
2010/Projects/WebApplication4/WebApplication4/Files/' is a physical
path, but a virtual path was expected.
Source Error:
Line 23: Line 24: //Upload and save the file Line 25:
string excelPath = Server.MapPath("c://users/agaabhis/documents/visual
studio 2010/Projects/WebApplication4/WebApplication4/Files/") +
Path.GetFileName(FileUpload1.PostedFile.FileName); Line 26:
FileUpload1.SaveAs(excelPath); Line 27:
Source File: c:\users\agaabhis\documents\visual studio 2010\Projects\WebApplication4\WebApplication4\Default.aspx.cs Line: 25

If you read the documentation for Server.MapPath on msdn, you'll find that you cannot hand it physical paths (which have a drive as a root). You need to give it paths relative to the server. For example:
string excelPath = Server.MapPath("Files/") + ...;

Related

Karate DSL: Cannot read file with certain characters in the file name [duplicate]

This question already has answers here:
Can we parameterize the request file name to the Read method in Karate?
(2 answers)
Closed 1 year ago.
I have these 3 files in the same directory. When the file has dash (-) or x in the name as below, karate cannot read the file and gives the error: org.graalvm.polyglot.PolyglotException: not found: image/image004-69.36.jpg
They are the same file in the same location, and when I rename the file to not have a dash (-) or x in the file name, it works. Are only certain characters allowed in a file name ? I am using MacOS Catalina version: 10.15.7 (19H15).
Here is the some code to recreate the problem. The first line works, the 2nd and 3rd line does not. If I rename to remove x and dash(-) from the filename, it works.
Scenario: Image Read
* print read('classpath:image/image004_69.36.jpg')
* print read('classpath:image/image004_69x36.jpg')
* print read('classpath:image/image004-69.36.jpg')
It worked with karate version 1.1.0. The problem was with version 1.0.1. I am leaving the question out, just in case anyone else has the same problem.

I need convert UTF-16 to ANSI [closed]

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 2 years ago.
Improve this question
How i can convert UTF-16 to ANSI in a .cmd file?
Your code has a UTF-16 LE byte-order-marker at the beginning of it, which an obfuscation technique developed on DosTips. Either remove it via a hex editor, or save this code as deobfuscate.bat and drag your script onto it:
#echo on &setlocal
if "%~1"=="" exit /b
if /i "%~x1" neq ".bat" if /i "%~x1" neq ".cmd" exit /b
<"%~1" ((for /l %%N in (1 1 8) do pause)>nul&findstr "^">"%~n1___%~x1")

Numpy cannot save with certain name(s) [duplicate]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Why in Windows, can't you name a folder 'con'?
Whenever I try to name a folder as "con" (without the quotes) it defaults to its original name.
Why does it do this?
Back in the MS-DOS days, "con" had a special meaning. It referred to the console, and allowed you to treat it like any other file. For example, you might create a new text file by typing copy con new.txt. Then you could enter your text and hit ^Z when finished.
The thing is, you can still do that. Therefore, as far as the file system is concerned there is already an object out there named con. There are other reserved names as well, but I see that while typing this those names have been provided already in other answers.
Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9
Source: MSDN
Other names, such as drive names, cannot be used as well:
CLOCK$, A:-Z:
Source: Microsoft support
Actually you can rename the folder to con
use this in the command prompt and this creates a system folder named con on your C: Drive
md \\\\\.\\\C:\con
to remove this folder you need to use this in the command prompt
rd/s \\\\.\\\C:\con
And just for those that are wondering "so why would you?" - my name is CON and if I wish to use that as my folder I WILL so "bugger you MS"
Con "OzDing"
This dates back to MS-DOS. Reading or writing to a file named "CON:" read/wrote from the console. I imagine Windows is still supporting this for backwards compatibility.
From Microsoft TechNet:
Several special file names are reserved by the system and cannot be used for files or folders:
CON, AUX, COM1, COM2, COM3, COM4,
LPT1, LPT2, LPT3, PRN, NUL

Installing stored procedure in .NET [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
My goal is trying to install stored procedures that are in .sql files. After doing some research, everyone recommended that my program reads in the .sql file into a string and create a command object from the string.
using System.Data.SqlClient;
public partial class ExecuteScript
{
static void Main(string[] args)
{
string sqlConnectionString = [connection string];
string script = File.ReadAllText([.sql file path]);
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
Here are some references:
How to execute an .SQL script file using c#
https://social.msdn.microsoft.com/Forums/en-US/43e8bc3a-1132-453b-b950-09427e970f31/run-a-sql-script-file-in-c?forum=adodotnetdataproviders
It is interesting that sqlcmd.exe takes in .sql file but SqlClient in .NET does not. Does anyone know why or how to? The reason I do not want to read in .sql file as a string is that all my stored procedures have comments at the top and reading them into a string makes the entire procedure into a sql comment. I understand I can fix this various ways but I was hoping to see if there is a easier way. I ended up doing the following but please enlighten me!
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "-E -d [database] -S [server\\instance] -i " + storedProcFullPath;
startInfo.FileName = "sqlcmd.exe";
Process.Start(startInfo);
Thanks!
Of course you can read your SQL file in .Net.
The problem you're experiencing is that File.ReadAllText strips your CR/LF when you read it into a string: How to read a file into a string with CR/LF preserved?
SOLUTION:
File.ReadAllBytes() to get all the bytes
Encoding.GetString() to convert the bytes to a string.
EXAMPLE:
byte[] data = File.ReadAllBytes("myfile.sql");
string text = Encoding.UTF8.GetString(data);

Show current class file [closed]

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 would like to NSLog the current class file that the simulator loads, in order to make sure the class file loaded currently. What parameter should I code?
Is it possible?
Thanks.
You can use the preprocessor directive __FILE__ to access the file path of the currently executing code. This flag is set at compile-time, but for usage in an NSLog, this shouldn't matter.
You can use it like this:
NSLog("Log called from file %s", __FILE__);
==> Log called from file /Developer Projects/Objective-C/Mac/test/test/AppDelegate.m
There are also other preprocessor variables you can use, such as __LINE__ and __PRETTY_FUNCTION__
You can define it in a preprocessor macro, and use it as such:
#define NSFileLog(format, ...) NSLog(#"%s:%d :: " format, __FILE__, __LINE__, ##__VA_ARGS__)
...
NSFileLog(#"Test Log");
==> /Developer Projects/Objective-C/Mac/test/test/AppDelegate.m:20 :: Test Log