|
|
DotNetCoderJunior wrote: does it matter if i asked for help twice
Yes, because it irritates people.
DotNetCoderJunior wrote: i'm that desperate...i got deadlines,and i can't find a solution to my problem
Then, you have one option, start looking for a different line of work.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi Guys,
I've got an windows forms application developed with c#.
My admin just rang me up, as he installed the application testwise on one of our client pc's, that he explicitly has to give the user the permission to write into the application directory.
the application is installed under c:\progam files\applicationDirectory. The application is using a xml-file to read and save application data.
my question is - what can I do to set the permissions correctly on pc's where the user is not neccessarily an administrator. (and I would like to leave the data xml within the applications directory, if possible...)
any suggestions are very welcome
thanks
piratenwichtl
|
|
|
|
|
You shouldn't store data in the application's folder. You should do that in the "special folder" where special permissions shouldn't be required. Here's some code that works on XP and Vista (apologies if it requires scrolling on your screen):
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MyLib
{
public class Utility
{
public static string CreateAppDataFolder(string folderName)
{
string appDataPath = "";
string dataFilePath = "";
folderName = folderName.Trim();
if (folderName != "")
{
try
{
appDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
}
catch (Exception ex)
{
throw ex;
}
if (folderName.Contains("\\"))
{
string[] path = folderName.Split('\\');
int folderCount = 0;
int folderIndex = -1;
for (int i = 0; i < path.Length; i++)
{
string folder = path[i];
if (folder != "")
{
if (folderIndex == -1)
{
folderIndex = i;
}
folderCount++;
}
}
if (folderCount != 1)
{
throw new Exception("Invalid folder name specified (this function only creates the root app data folder for the application).");
}
folderName = path[folderIndex];
}
}
if (folderName == "")
{
throw new Exception("Processed folder name resulted in an empty string.");
}
try
{
dataFilePath = System.IO.Path.Combine(appDataPath, folderName);
if (!Directory.Exists(dataFilePath))
{
Directory.CreateDirectory(dataFilePath);
}
}
catch (Exception ex)
{
throw ex;
}
return dataFilePath;
}
}
}
using MyLib;
string dataFolder = Utility.CreateAppDataFolder("MyAppFolder");
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
thanks guys for your answers.
I will have a look into each suggestion.
but i probably dont get around playing with the user permission, because the software is doing a self-update as well for example - means, the software needs the rights to write into the application folder to perform all the action neccessary to update the application.
I see microsofts idea of using these user-directories for storing user data belonging to the application - but I dont like it. I would like to have everything belonging to the application in one single directory.
but thanks anyway
cheers
piratenwichtl
|
|
|
|
|
|
Hi guys,
any idea to display image in webpage directly from database (image control need url) i want to display it without url is it possible? or any other way to do this?
|
|
|
|
|
Aside from the fact you have posted this question in the wrong place (it should be in the ASP.NET forum[^]), you have already received the answer to this question from Guffa here[^]
He said: "you need a proxy page that gets the image data from the database and writes it to the response stream, and you use the url of the proxy page as ImageUrl".
Simon
|
|
|
|
|
Stop asking the same question again and again. Start reading and exploring the answers that were given to you. That's the way to learn programming.
|
|
|
|
|
Hi,
Iam creating picture box dynamically but iam getting this error,
CODE:
PictureBox pb = new PictureBox();
Form.Controls.Add(pb); //Error is in this line//
The error comment is:
The best overloaded method match for 'System.Web.UI.ControlCollection.Add(System.Web.UI.Control)' has some invalid arguments.
|
|
|
|
|
You can't put windows controls in a web page.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Then any idea to display image in webpage directly from database (image control need url) i want to display without url is it possible?
|
|
|
|
|
No, that is not possible. The browser requests the image separately from the page, so it needs an url to request it from.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You need to set up a proxy page, which reads the image data from the database and writes it to the output stream. Then you set the ImageUrl to the url of your proxy page.
|
|
|
|
|
there are several options
- if you can take out the files from the database, you can set them in a directory and save the paths instead.
- if that's not an option, stream the file to a tmp directory and set the url to that path, when the session expires you delete the files used within that session (you'll need a good naming convention...)
hope this helps.
|
|
|
|
|
You forgot the solution that doesnt require writing the data to disk, which the OP has now been given >3 times.
|
|
|
|
|
I have a design problem here.
in the BIL there are some classes that represent business entities
each of this class is static. and they all have mostly the same (static) members :
- some info methods like give the pk for that entity
- perform some actions on it: search for that specific business entity.
- and so on
I want to enforce that some methods are implemented on each static class.
how can I do it ? note that interfaces don't work here since it is a static class
maybe the design is wrong here, better alternatives ?
<< Nearly all men can stand adversity, but if you want to test a man's character, give him power. >>
|
|
|
|
|
No, unfortunately, static classes must derive from Object and nothing else, and neither interfaces or abstract classes can be static anyway.
It's hard to comment on your design without seeing the whole thing, but I would suggest that yes, to have static classes representing business entities is a bit of a strange design.
Again, it's hard to suggest alternatives without seeing everything you are trying to do, but a pretty standard way is to have a bunch of business objects that define your business entities, these can then be created 1 for each entity and store all the values, and can possibly inherit from a base entity object.
Simon
|
|
|
|
|
Hi All
Iam Using the SqlConnection To Connect To Sql Server 2005
And the connecte is Done .
I wount to Connecte to Sql Server 2005 By Using OledbConnection Or ODBCConnection , My Quesion Is :
how I Can Connecte to Sql Server 2005 With OLedbConnection Or ODBCConnection ? and it is a Write Connect ?
Thanks For any body help me
Thaer
|
|
|
|
|
Take a look here[^], It might help you.
Life is 5: 3 me, 1 you.
|
|
|
|
|
Ok Thanks Mr Pedram Behroozi
iwount To Know Can I Use The ODBCConnection Or OledbConnection to Connecte to Sql Server 2005
Thaer
|
|
|
|
|
I think so but OdbcConnection requires an ODBC driver for the database while OleDbConnection requires an OLEDB provider (it's suitable for MSAccess or Oracle). Why don't you use SqlConnection? It's more efficient when using SQL Server because there is no OLEDB provider in between.
Life is 5: 3 me, 1 you.
|
|
|
|
|
Yes, you can use ODBCConnection to connect to a SQL Server database, however, you really should use SQlConnection, which is specifically written for SQL Server. ODBC connections are necessarily generic where as the SQL connection offers enhanced performance and capabilities specific to SQL Server.
only two letters away from being an asset
|
|
|
|
|
OledbConnection is not For SQL
SqlConnection is for SQL, ODBCConnection is Fine, but i suggest you use ODBCConnection
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|