|
See Directory Methods (System.IO)[^]. You will need to start at the root and enumerate all directories recursively until you find the one you are looking for.
|
|
|
|
|
thanks for your reply.
Got the solution, but ends up with another problem "Access to the path 'D:\System Volume Information' is denied" . And i didn't find any solution to this. So instead of placing the Data_base anywhere i decided to place it in the application installation folder itself.
Now the path can be easily read by using the code in runtime
string appFileName = Environment.GetCommandLineArgs()[0];
string directory = Path.GetDirectoryName(appFileName);
MessageBox.Show(directory);
|
|
|
|
|
Quote: The System Volume Information folder is a hidden system folder that the System Restore tool uses to store its information and restore points. There is a System Volume Information folder on every partition on your computer.
Never store user data in the application folder. A normal user did not have write access when using the recommended Progam Files folder. Use one of the application data folders instead. Which one to use depends on roaming support and if shared access is required. See the AppData properties in the Application Class (System.Windows.Forms)[^] to get these pathes.
|
|
|
|
|
Thanks for the reply...
i don't want to use System Volume Information folder. But during enumeration process automatically the checking comes here, then generates an exception and terminates further execution. Is there any method to avoid these kind of system folders checking during enumeration?.
|
|
|
|
|
When you expect exceptions to be thrown catch them to avoid that the application terminates. In this case just ignore access denied exceptions and continue.
But there is no need to enumerate all directories when using a standard Windows folder for your application data.
|
|
|
|
|
|
thanks for the reply. . .
|
|
|
|
|
private static List<string> BadNames = new List<string>{"Adobe","CPMigrator","ServicePack","Symantec", "Server", "TumbleWeed"};
private static string targetFolder = "Common7";
static void Main(string[] args)
{
List<string> folders = GetFolders(@"C:\Program Files\");
string found = folders.FirstOrDefault(x=>x.ToUpper().EndsWith(targetFolder.ToUpper()));
}
public static List<string> GetFolders(string path)
{
List<string> folders = new List<string>();
foreach(string bad in BadNames)
{
if (path.ToUpper().Contains(bad.ToUpper()))
{
return folders;
}
}
try
{
folders = Directory.GetDirectories(path, "*.*", SearchOption.TopDirectoryOnly).ToList();
for (int i = 0; i <folders.Count; i++)
{
folders.AddRange(GetFolders(folders[i]));
}
}
catch (Exception)
{
}
return folders;
}
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 13-Apr-18 9:41am.
|
|
|
|
|
Smallest window in a string containing all the characters of another string
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Looks a bit spammy to me.
|
|
|
|
|
The username does, but the message is clear of pink meat. And the user has been here for nearly two years.
I'll give it the benefit of the doubt for the moment - company names for your username are allowed.
Mind you, if he can't do that homework himself, I wouldn't use the company...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I am in the process of creating an intranet system for a local business. This system will contain a custom CRM, as well as various other components essential to the customers business.
They will shortly be switching their phone system to Skype.
We would like to develop a C# desktop app that talks with the skype application to detect when a phone call comes in, then flashes up various information for the user - such as customer name and account status.
Is there an API that will allow us to do this?
|
|
|
|
|
|
Except no-where on that page does it tell me how to integrate a C# application with skype. I don't want to create a bot, accept payments, conduct interviews or add call links to my web app.
I want to detect incoming calls on skype, and flash up additional data on the users screen.
And to clarify, I'm talking *desktop* application, not mobile.
modified 11-Apr-18 9:21am.
|
|
|
|
|
Sonetimes I think the better question is: How to turn Skype off ... cameras, mikes, status monitors, background zombies.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I created an excel user defined function using excel dna Add-In, My function should return a two dimentional array but when i call it from a cell (=mainView(2018-04-10) ) it displays only the first column name (FundName), below is my code:
<pre> public static object[,] mainView(DateTime dt)
{
int rows = 0;
int columns = 0;
const int columnsArrayIndex = 0;
DataTable dt = new DataTable();
object[,] allRecords = new object[0,0];
try
{
SqlConnection cnx = new SqlConnection("data source=...;initial catalog=...;integrated security=True");
cnx.Open();
string query = @"select FundName,...";
SqlCommand cmd = new SqlCommand(query, cnx);
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
{
a.Fill(dt);
rows = dt.Rows.Count;
columns = dt.Columns.Count;
if (columns > 0 && rows > 0)
{
allRecords = new object[rows + 1, columns];
for (int i = 0; i <= columns - 1; i++)
{
allRecords[columnsArrayIndex, i] = dt.Columns[i].ColumnName;
}
for (int j = 0; j <= rows - 1; j++)
{
var rowItem = dt.Rows[j].ItemArray;
for (int k = 0; k <= rowItem.Length - 1; k++)
{
allRecords[j + 1, k] = rowItem[k];
}
}
}
}
}
catch
{
}
return allRecords;
} I would like to get all the rows of the select query result displayed in the excel, the result of the select query is dynamic, it changes when the date changes. What is missing in my code please so that i can get the result i want ? how can i display all the rows and columns of my query in the excel ?
|
|
|
|
|
I would suggest getting rid of the empty Catch block. There could be exceptions occurring, but you have no idea what they are because you're ignoring them.
Once you know what exceptions are occurring, you can solve them.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I've never done such things, however I don't expect the content of a 2D array can be accepted by a single cell. You probably need to select a range of the correct size, then assign your UDF to the first cell of that range.
BTW: your code is very confusing as it seems to be using too many variable names to achieve what you want. And please never have an empty catch block, it will waste your and our time by NOT showing a lot of things that may be going wrong. Always catch an Exception and show the its entire ToString() result to the developer (and possibly later to the user).
|
|
|
|
|
Thank you, i found an example that returns the result in a range but when i did the same as the example i got an exception
"Exception de HRESULT : 0x800A03EC"
in this line
range.Value2 = result;
this is my code :
public static void LoadData(object[] args)
{
int rowPosition = Convert.ToInt32(args[0]);
int columnPosition = Convert.ToInt32(args[1]);
string sheetName = (string)args[2];
var application = (Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application;
var sheet = application.Sheets[Regex.Replace(sheetName, @"\[[^]]*\]", string.Empty)];
object[,] result = LoadFromDbData();
var startcell = sheet.Cells[rowPosition + 1, columnPosition + 1];
int rowCount = result.GetUpperBound(0)-result.GetLowerBound(0)+1;
int colCount = result.GetUpperBound(1)-result.GetLowerBound(1)+1;
var endcell = sheet.Cells[rowPosition+ rowCount, columnPosition+colCount];
try
{
Range range = (Range)sheet.Range(startcell, endcell);
range.Value2 = result;
}
catch (COMException e)
{
MessageBox.Show(e.Message);
}
}
|
|
|
|
|
Hi,
I have no idea what is going wrong, however this guy[^] probably knows.
And maybe looking at Exception.ToString() rather than Exception.Message would have helped too, as I told you before.
|
|
|
|
|
Hello,
I am new in MVC. I have one product table which has ProductID, ProductName and ProductRate. I have one dropdown list which has all the ProductName. Now I am trying to select the productname and upon this select, it should fill my textbox with ProductRate. Code is as below but it is not doing anything and no errors. Please help.
<script type="text/javascript">
function GetPrice(_this) {
var x = document.getElementById("productID"), selectedValue = x.value;
alert("_this" + _this.SelectedValue);
var pid = selectedValue;
alert(pid);
var url = '@Url.Action("GetPrice","Sales")';
alert(url);
$.ajax({
type:"POST",
url: 'Sales/GetPrice',
contentType: "application/json; charset=utf-8",
data: {ProductId: pid },
cache:false,
dataType: json,
async: true,
processData:false,
success: function (data)
{
alert("yay1");
},
failure: function (response) {
alert("Fail");
}
});
};
</script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-field">
<div class="editor-label">
@Html.LabelFor(model => model.ProductId)
</div>
@Html.DropDownListFor(model => model.ProductId, new SelectList(ViewBag.ProductList, "ProductId", "ProductName" ), "Select Product", new { id = "productID", onchange="GetPrice(this);"})
@Html.ValidationMessageFor(model => model.ProductId, "", new { @class = "text-danger" })
<span class="glyphicon glyphicon-asterisk"></span>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Rate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Rate, new { id = "idRate"})
@Html.ValidationMessageFor(model => model.Rate)
</div>\
</fieldset>
}
Here is my Controller "SalesController.cs" code:
[HttpPost]
public JsonResult GetPrice(int ProductId)
{
return Json("");
}
Dhyanga
modified 9-Apr-18 11:49am.
|
|
|
|
|
I am able to fix it.
Please disregard this post.
Dhyanga
|
|
|
|
|
Hi guys, I have some code here written in C++ which creates 3x3 matrixes. I believe that it's using EmguCV Matrix. However, I planned to convert this into C# language but I've failed to do so. To the best of my knowledge, most online solutions guide me to use an array. Therefore, I wish to know is anyone expert in C# that may help me explain how can I convert this code to C#? I wish to know the syntax of it in C#. Thank you
<pre>Mat eulerAnglesToRotationMatrix(Vec3f &theta)
{
Mat R_x = (Mat_<double>(3,3) <<
1, 0, 0,
0, cos(theta[0]), -sin(theta[0]),
0, sin(theta[0]), cos(theta[0])
);
Mat R_y = (Mat_<double>(3,3) <<
cos(theta[1]), 0, sin(theta[1]),
0, 1, 0,
-sin(theta[1]), 0, cos(theta[1])
);
Mat R_z = (Mat_<double>(3,3) <<
cos(theta[2]), -sin(theta[2]), 0,
sin(theta[2]), cos(theta[2]), 0,
0, 0, 1);
Mat R = R_z * R_y * R_x;
return R;
}
|
|
|
|
|
The "EmuguCV Matrix" sample you are showing is using a "Mat" class; why do you think that arbitrarily using an "array" instead (because the "internet" says so) makes sense?
Mind you, I know nothing about C++ other than I dislike it because of MFC, etc. ...
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|