Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
My code
string userid;
string userimageid;
bitmap.save(#"C:\temper\temp\"+userid+"\"+userimageid+".jpg");
get build error! why canĀ“t I create subfolder with string value name and insert image? still cant insert to that crated folder as name userid.
Yes, you can. But you must create first the folder and then save the bitmap:
string folderName = #"C:\temper\temp\"+userid;
if (!Directory.Exists(folderName) {
Directory.CreateDirectory(folderName);
}
bitmap.save(folderName + "\\userimage.jpg"); //your original concatenation had an error
Solved!
string folderName = #"C:\temper\temp\"+userid;
if (!Directory.Exists(folderName) {
Directory.CreateDirectory(folderName);
}
bitmap.save(folderName + "\\" +userimage+ ".jpg"); `Create first folder and save Thanks Mnieto`
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
Here is my code
RegistryKey = regsohr;
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
sw.WriteLine(regsohr.GetValue("Path"));
It can't get into {DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}.
But when I delete that line everything works fine.
Anyone has any ideas why it can't open this SubKey?
I will appreciate any help.
My bad.
I have messed up with "HKEY_LOCAL_MACHINE".
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Fixed it
regsohr = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Try this , for example i put it in a Label to check if it works
{
string readValue;
readValue = My.Computer.Registry.GetValue
(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache", "Tasks",Nothing);
Label6.Text = readValue;
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm developing a programm and the programm schould delete a cache. The only problem is that all the files in the cache have no extensions and always when I try to delete those files I get an exception: The access to the path 'path' was denied. So I don't know why this error occurs because I'm trying to delete a file and not a directory. I think it doesn't recognises the file as a file because of the missing extension.I've etried this:
DirectoryInfo cache = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + #"\Cache");
Console.WriteLine("Deleting Cache...");
foreach (var fi in cache.GetFiles())
{
File.Delete(cache + #"\" + fi.Name);
Console.WriteLine(cache + #"\" + fi.Name);
}
Console.ReadKey();
What else can I try?
It seems your file was still open, so you can't delete it. However, my original answer still applies:
Since you already have a DirectoryInfo, you dont need to concatenate the strings to get the file-name, just use FileInfo.Delete:
foreach (var fi in cache.GetFiles())
{
fi.Delete();
}
You should avoid concatenating strings to build a path anyway, use Path.Combine:
DirectoryInfo cache = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cache"));
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
public string ReplaceTest(int i)
{
string rep = this.textBox3.Text;
string reped = rep.Replace("sir, this.textBox3.Text");
}
Like this? this is what i want to do but another error comes up not all code paths return a value
string.Replace() takes two arguments:
the string to replace
the string to use instead
If you want to remove "sir", it means to replace it with an empty string:
string reped = rep.Replace("sir", string.Empty);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
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.
Improve this question
At the moment I'm currently trying to get all files from a specified directory. The files I'm looking for end with the file type .ship, however, my code returns "path\NameOfFiles.ship.ship" and I can't for the life of me decide where the extra file extension is added.
Here's the function I use
public static List<SaveEntry> GetAllSavesFromProfile(string ProfileName)
{
if (IsProfileMissing(ProfileName))
{
Debug.LogError("Couldn't find save from profile. Check if it exists before calling this function");
return new List<SaveEntry>();
}
List<SaveEntry> ListToReturn = new List<SaveEntry>();
List<string> SaveEntries = Directory.GetFiles(Application.persistentDataPath + "/Profile_" + ProfileName, "*", SearchOption.TopDirectoryOnly).Where(s => s.EndsWith(".ship", StringComparison.CurrentCultureIgnoreCase)).ToList<string>();
foreach (string entry in SaveEntries)
{
ListToReturn.Add(LoadShip(ProfileName, entry));
}
return ListToReturn;
}
I'm pretty I'm doing something wrong with the Where function, but I can't decide exactly where.
I suspect your filenames contains an extra .ship. You can verify that if you change your settings to show file extensions.
Also, you can use a search pattern instead of using Where
Directory.GetFiles(Application.persistentDataPath + "/Profile_" + ProfileName, "*.ship", SearchOption.TopDirectoryOnly)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
This is my code (.Net 4):
string dName = textBox1.Text + ".db";
string fExist = #"C:\word_app\" + dName;
if (!File.Exists(fExist))
{
MessageBox.Show("file doesnt exist");
}
Even if I have the file in that location , this messagebox will appear.
you have just to correct your path (its words not word)
string dName = textBox1.Text + ".db";
string fExist = #"C:\words_app\" + dName;
if (!File.Exists(fExist))
{
MessageBox.Show("file doesnt exist");
}